[CLOSED] dynamically adding columns to gridpanel

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [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:
    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]

Similar Threads

  1. [CLOSED] Adding aspx Gridpanel to dynamically created tab
    By ASAPCH in forum 2.x Legacy Premium Help
    Replies: 7
    Last Post: Dec 06, 2012, 2:47 PM
  2. [CLOSED] Dynamically adding portal columns
    By SymSure in forum 2.x Legacy Premium Help
    Replies: 8
    Last Post: Oct 12, 2012, 2:32 PM
  3. Replies: 3
    Last Post: Mar 30, 2010, 1:03 PM
  4. Replies: 2
    Last Post: Nov 25, 2009, 8:35 AM
  5. [CLOSED] Any chance of adding frozen columns to GridPanel?
    By jchau in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Jul 22, 2009, 12:21 PM

Tags for this Thread

Posting Permissions