We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Error when modifying dynamically generated columns

Hi :)


An error occurs when modifying dynamically generated columns in the grid.

 The [Work Master] and [Material Master] columns created with HTML tags are modified normally. However, dynamically generated columns [Total Qty.], [OPP-101-001], [OPP-101-002], and [OPP-101-003] have errors when double-clicked for Edit.


Please refer to the attached video with an error and the cshtml, controller, and model files on the page.


I would appreciate it if you could solve it as soon as possible.


Attachment: Grid_edit_bug_2889de10.7z

3 Replies 1 reply marked as answer

RS Rajapandiyan Settu Syncfusion Team December 7, 2022 10:58 AM UTC

Hi Taewook,


Thanks for contacting Syncfusion support.


You can resolve the reported problem by creating a column with null Uid in the controller side. The refreshColumns method binds the respective uid value to that column. Find the below code and sample for your reference.


 

[HomeController.cs]

        [HttpPost]

        public IActionResult GridHeaderAndDataBinding(string sJobNo, string sMtoSeq)

        {

 

                List<GridColumn> headerList = new List<GridColumn>();

                GridColumn workTotal = new GridColumn

                {

                    Field = "WORK_TOTAL",

                    HeaderText = "Work",

                    HeaderTextAlign = TextAlign.Center,

                    TextAlign = TextAlign.Right,

                    Width = "100",

                    Uid = null

                };

 

                GridColumn matlTotal = new GridColumn

                {

                    Field = "MATL_TOTAL",

                    HeaderText = "Material",

                    HeaderTextAlign = TextAlign.Center,

                    TextAlign = TextAlign.Right,

                    Width = "100",

                    Uid = null

                };

 

                List<GridColumn> totalColumns = new List<GridColumn>();

                totalColumns.Add(workTotal);

                totalColumns.Add(matlTotal);

 

                GridColumn totalQty = new GridColumn

                {

                    HeaderText = "Total Qty.",

                    HeaderTextAlign = TextAlign.Center,

                    TextAlign = TextAlign.Center,

                    Columns = totalColumns

                };

 

                headerList.Add(totalQty);

 

                for (int i = 0; i < 1; i++)

                {

                    GridColumn workQtyCol = new GridColumn

                    {

                        Field = $"WORK_QTY{i}",

                        HeaderText = "W.Qty.",

                        HeaderTextAlign = TextAlign.Center,

                        TextAlign = TextAlign.Right,

                        Width = "100",

                        Uid = null

                    };

 

                    GridColumn matlQtyCol = new GridColumn

                    {

                        Field = $"MATL_QTY{i}",

                        HeaderText = "M.Qty.",

                        HeaderTextAlign = TextAlign.Center,

                        TextAlign = TextAlign.Right,

                        Width = "100",

                        Uid = null

                    };

 

                    List<GridColumn> QtyColumns = new List<GridColumn>();

                    QtyColumns.Add(workQtyCol);

                    QtyColumns.Add(matlQtyCol);

 

                    GridColumn parentCol = new GridColumn

                    {

                        HeaderText = "Dynamic",

                        HeaderTextAlign = TextAlign.Center,

                        TextAlign = TextAlign.Center,

                        Columns = QtyColumns

                    };

 

                    headerList.Add(parentCol);

                }

                List<object> returnList = new List<object>();

                returnList.Add(headerList);

                returnList.Add(BigData.GetAllRecords());

                return Json(returnList);

        }


Sample:
https://www.syncfusion.com/downloads/support/directtrac/general/ze/core_grid_dynamicColumns_uid-1468162161.zip

Regards,

Rajapandiyan S


Marked as answer

TK TaeWook Kang December 9, 2022 06:49 AM UTC

It's perfect.

Thank you always!



SG Suganya Gopinath Syncfusion Team December 11, 2022 11:51 AM UTC

Taewook,

We are glad that the provided sample worked to solve the issue. Please get back to us for further assistance.

We are marking this thread as solved. 

Regards,

Suganya Gopinath.


Loader.
Live Chat Icon For mobile
Up arrow icon