Jun 25, 2015, 1:37 PM
[CLOSED] dynamically adding columns to gridpanel
I have a grid panel like the one below(provided view code), now I want to add some more columns to it dynamically. To be more precise, I have some data columns coming from server and those are now configured into a datatable, and now that datatable columns need to be merged with the columns of the gridpanel (these grid panel columns are created in markup and the data coming from database) at the runtime and then loaded. Also, I have no information on data columns coming from data table(like column name and column data type), means I have to check the data table first, iterate over each column and then fetch their names and datatype at runtime which is then added to gridpanel. So , anyone please help me how to do that? Thanks
view code:
view code:
X.GridPanel().Title("Update Grid").ID("updateGrid").Layout(LayoutType.Fit).Flex(7).Border(false).AutoScroll(true).Region(Region.Center)
.Store
(
X.Store().ID("updateStore").Sorters(X.DataSorter().Property("Name").Direction(Ext.Net.SortDirection.ASC))
.Model
(
X.Model()
.Fields
(
new ModelField("Id", ModelFieldType.Object),
new ModelField("Name", ModelFieldType.String),
new ModelField("IsEnabled", ModelFieldType.Boolean),
new ModelField("Status", ModelFieldType.String)
)
)
)
.ColumnModel
(
X.Column().Text("Name").DataIndex("Name")
.HeaderItems(
X.TextField().ID("hdrName").Listeners(l => { l.Change.Handler = "jsApplyFilter(this);"; l.Change.Buffer = 250; }).Plugins(X.ClearButton())
),
X.Column().Text("Status").DataIndex("Status").HeaderItems(
X.TextField().ID("hdrStatus").Listeners(l => { l.Change.Handler = "jsApplyFilter(this);"; l.Change.Buffer = 250; }).Plugins(X.ClearButton())
),
X.ComponentColumn().Text("IsEnabled").DataIndex("IsEnabled").Editor(true).Align(Alignment.Center)
.HeaderItems(
Html.X().Container().Layout(LayoutType.VBox).LayoutConfig(new VBoxLayoutConfig { Align = VBoxAlign.Center })
.Items(
Html.X().Button()
.ID("Update")
.Icon(Icon.GroupEdit)
.ToolTip("Update All")
.Listeners(li => { li.Click.Handler = "UpdateAll();"; })
)
)
.Component
(
X.Checkbox()
),
X.ImageCommandColumn().ToolTip("Edit").Commands
(
X.ImageCommand().CommandName("Edit").Icon(Icon.TableEdit).Text("Edit")
)
.Listeners(l => { l.Command.Handler = "EditData(record.data);"; }),
X.ImageCommandColumn().ToolTip("Update").Text("Update").Commands
(
X.ImageCommand().CommandName("Update").Icon(Icon.TableAdd).Text("Update")
)
.Listeners(l => { l.Command.Handler = "UpdateRecord(record.data);"; })
)
Last edited by Daniil; Jul 09, 2015 at 3:42 PM.
Reason: [CLOSED]