[CLOSED] How to update Component column value of one row on edit of component column of another row

  1. #1

    [CLOSED] How to update Component column value of one row on edit of component column of another row

    Hi,
    I have one grid with component column, and I want to update value of one component column of one row on edit of component column of another row.

    Below is code for page with javascript function which is called on edit of component column. I set value in store, but unable to reflect it on grid.

    Let me know if I am missing something or doing something wrong. Or if there is much easier way to do same.

    @model System.Collections.IEnumerable
    
    @{
        ViewBag.Title = "ComponentColumn Editor - Ext.NET MVC Examples";
        Layout = "~/Views/Shared/_BaseLayout.cshtml";
    }
    @section headtag
    {
        <script>
            function chngValue(editor, e) {
                debugger;
                var vv = e.value;
                e.grid.store.getAt(3).set('ComboBox', vv);
                //e.grid.reload();  //giving me an error
            }
        </script>    
    }
    @section example
    {    
        <h1>ComponentColumn as Editor</h1>
    
        @(Html.X().GridPanel()
            .Title("ComponentColumn Editor")
            .Width(600)
            .Height(300)
            .Store(Html.X().Store()            
                .Model(Html.X().Model()
                    .Fields(
                        new ModelField("IntField", ModelFieldType.Int),
                        new ModelField("ComboField", ModelFieldType.Int),
                        new ModelField("TextField", ModelFieldType.String),
                        new ModelField("DateField", ModelFieldType.Date)
                    )
                )
                .DataSource(Model)
            )
            .ColumnModel(
                Html.X().ComponentColumn()
                    .Editor(true)
                    .DataIndex("IntField")
                    .Flex(1)
                    .Text("Integer")
                    .Component(Html.X().NumberField()),
                    
                Html.X().ComponentColumn()
                    .Editor(true)
                    .DataIndex("ComboField")
                    .Flex(1)
                    .Text("ComboBox")
                    .Listeners(ls=>ls.Edit.Fn="chngValue")
                    .Component(Html.X().ComboBox()
                        .Items(
                            new ListItem("Item 1", 1),
                            new ListItem("Item 2", 2),
                            new ListItem("Item 3", 3),
                            new ListItem("Item 4", 4),
                            new ListItem("Item 5", 5),
                            new ListItem("Item 6", 6),
                            new ListItem("Item 7", 7),
                            new ListItem("Item 8", 8),
                            new ListItem("Item 9", 9)
                        )
                    ),
                    
                Html.X().ComponentColumn()
                    .Editor(true)
                    .DataIndex("TextField")
                    .Flex(1)
                    .Text("Text")
                    .Component(Html.X().TextField()),
                    
                Html.X().ComponentColumn()
                    .Editor(true)
                    .DataIndex("DateField")
                    .Flex(1)
                    .Text("Date")
                    .Component(Html.X().DateField())
            )
        )
    }
    Last edited by Daniil; Aug 21, 2014 at 9:01 AM. Reason: [CLOSED]
  2. #2
    Hi @PriceRightHTML5team,

    The ModelField names mismatch:
    new ModelField("ComboField", ModelFieldType.Int)
    e.grid.store.getAt(3).set('ComboBox', vv);
  3. #3
    Thank you Daniil. Its working fine for me.

Similar Threads

  1. [CLOSED] Gridpanel component Column in CodeBehind
    By ebeker in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Nov 07, 2013, 9:39 PM
  2. Replies: 4
    Last Post: Jul 30, 2013, 4:19 AM
  3. Replies: 2
    Last Post: Jun 27, 2013, 10:18 PM
  4. [CLOSED] How to disable component column editor
    By bayoglu in forum 2.x Legacy Premium Help
    Replies: 6
    Last Post: Jun 19, 2013, 7:16 PM
  5. [CLOSED] selectbox in component column
    By marco.morreale in forum 2.x Legacy Premium Help
    Replies: 7
    Last Post: Feb 18, 2013, 3:25 PM

Posting Permissions