Unigrid with dynamic columns

Lokendra Jain asked on March 25, 2017 08:39


I am developing a custom webpart to display custom table data with edit and delete button.

I have created two properties for webpart 1. CustomTable 2. Columns.

On code behind i am able to fetch the data using custom table api. Now i need to show the column dymically on the unigrid.

How to do the functionality to show the columns as user added into columns property of the webpart.

Please suggest.


Lokendra Jain

Recent Answers

vasu yerramsetti answered on March 25, 2017 18:52 (last edited on March 26, 2017 12:38)

You can achieve your requirement using UniGrid and XML file as GridName. See below code snippet.

Sample XML File Code:
<?xml version="1.0" encoding="utf-8"?>
    <column source="ItemText" />
    <column source="ItemCreatedBy" />

Use full URLs: https://forums.asp.net/t/1407620.aspx?Good+Example+of+how+to+create+a+Xml+Document+Programmatically+ https://docs.kentico.com/k8/references/kentico-controls/ui-controls/unigrid/reference-unigrid-definition

Web Part Code:
<cms:UniGrid ID="UserGrid" runat="server" />
Code behind:
protected void SetupControl()
        if (this.StopProcessing)
            // Do not process
            GenerateXML("ItemText,ItemCreatedBy");//Columns value from web part property
            UserGrid.GridName = "~/CMSWebParts/Custom/Test.xml";
            UserGrid.ObjectType = "CustomTableItem.customtable.SampleTable";// CustomTable name from web part property
            UserGrid.Columns = "ItemID,ItemText,ItemCreatedBy";//Columns value from web part property
 private void GenerateXML(string columns)
    //Todo [Dynamic XML generate code here and Use foreach for generate XML child nodes dynamically]
1 votesVote for this answer Mark as a Correct answer

Roman Hutnyk answered on March 27, 2017 16:30 (last edited on March 27, 2017 16:31)

There is a free web part on the Marketplace developed by Brenden Kehren. It allows custom table data editing. Use it for your application or inspiration.

2 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.