[CLOSED] Syntax to get grid panel row index to filter comboBox data inside grid panel

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Syntax to get grid panel row index to filter comboBox data inside grid panel

    Hi,

    Please refer the highlighted area in the image attached with this thread.
    This code is working with hard coded row index.
    I need the syntax to get grid panel row index while filtering of records for combo box inside grid panel.

    Thanks
    Attached Thumbnails Click image for larger version. 

Name:	GridPanel_ComboBox.jpg 
Views:	72 
Size:	50.5 KB 
ID:	5726  
    Last edited by Daniil; Mar 04, 2013 at 12:51 PM. Reason: [CLOSED]
  2. #2
    Component bind is performed on the client side therefore you cannot do it on the server side
    I can suggest to use associations

    Controller
    public class OverviewController : Controller
        {
            public ActionResult Index()
            {
                return View(new List<object> { 
                    new { Index= 1, ComboItems = new List<object>{ 
                        new {value = 1, text = "Item1 for index=1"},
                        new {value = 2, text = "Item2 for index=1"},
                        new {value = 3, text = "Item3 for index=1"}
                    }},
    
    
                    new { Index= 2, ComboItems = new List<object>{ 
                        new {value = 1, text = "Item1 for index=2"},
                        new {value = 2, text = "Item2 for index=2"},
                        new {value = 3, text = "Item3 for index=2"}
                    }},
    
    
                    new { Index= 3, ComboItems = new List<object>{ 
                        new {value = 1, text = "Item1 for index=3"},
                        new {value = 2, text = "Item2 for index=3"},
                        new {value = 3, text = "Item3 for index=3"}
                    }}
                });
            }       
        }
    View
    @model System.Collections.IEnumerable
               
    @using System.Collections.Generic
    
    
    @{
        ViewBag.Title = "ComponentColumn Overview - Ext.NET MVC Examples";
        Layout = "~/Views/Shared/_BaseLayout.cshtml";
    }
    
    
    @section example
    {        
        @(Html.X().Model()
            .Name("ComboItem")
            .Fields(
                new ModelField("text"),
                new ModelField("value", ModelFieldType.Int)
            )
         )
    
    
        @(Html.X().GridPanel()
            .Title("ComponentColumn Overview")
            .Width(320)
            .Height(180)
            .Store(Html.X().Store()
                .Model(Html.X().Model()
                    .Fields(
                        new ModelField("Index", ModelFieldType.Int)                    
                    )
                    .Associations(a=>{
                        a.Add(new HasManyAssociation { Model = "ComboItem", Name = "comboItems", AssociationKey = "ComboItems" });
                    })
                )
                .Data(Model)
            )
            .ColumnModel(
                Html.X().RowNumbererColumn(),
                
                Html.X().ComponentColumn()
                    .Flex(1)
                    .DataIndex("Index")
                    .Editor(true)
                    .Component(Html.X().ComboBox()
                        .Flex(1)
                        .DisplayField("text")
                        .ValueField("value")
                        .QueryMode(DataLoadMode.Local)
                        .TriggerAction(TriggerAction.All)
                        .Store(Html.X().Store()                        
                            .AutoLoad(false)
                            .ModelName("ComboItem")
                        )
                    )
                    .Listeners(l=>l.Bind.Handler = "cmp.store.add(record.comboItems().getRange());")
            )
    
    
        )
    }
  3. #3

    I tried with the suggested way

    Hi,

    I tried with the way you suggested.
    There seems some problem with the below line of code: -

    .Listeners(l=>l.Bind.Handler = "cmp.store.add(record.MasteryNames().getRange());" )

    Also, I am not very clear what exactly is written or should be written inside the string which is assigned to the handler above.

    - what is 'cmp.store.add'? do i need to write the same or something else in my context?
    - 'record.MasteryNames().getRange()' give error as 'MasteryNames' is not an identified method. If I remove the brackets, it gives error as 'MasteryNames' is undefined.

    Below is my code sample for reference: -
    Let me know what correction is required here.

    Model: -

    CompetencyMasteryDTO

    [DataContract]
        public class CompetencyMasteryDTO
        {
            [DataMember]
            public int Position_Grade_Id { get; set; } 
    
            [DataMember]
            public int Competency_Mastery_Id { get; set; } 
    
            [DataMember]
            public int Competency_Id { get; set; } 
    
            [DataMember]
            public int Mastery_Id { get; set; } 
    
            [DataMember]
            public string Competency_Name { get; set; } 
    
            [DataMember]
            public string Mastery_Name { get; set; } 
    
            [DataMember]
            public int Is_Active { get; set; } 
    
            [DataMember]
            public int Competency_Mastery_Assignment_Id { get; set; }                           
    
            [DataMember]
            public List<MasteryDTO> List_Mastery { get; set; }
            [DataMember]
            public Int32 List_CompetencyId { get; set; }
        }
    MasteryDTO

    
    [DataContract]
        public class MasteryDTO
        {
            [DataMember]
            public int Mastery_Id;
    
            [DataMember]
            public int Competency_Mastery_Id { get; set; }
    
            [DataMember]
            public int Competency_Id { get; set; }
    
            [DataMember]
            public string Mastery_Name;
    
            [DataMember]
            public string Mastery_Desc;
    
            [DataMember]
            public int Badge_Id;
    
            [DataMember]
            public int Is_Active;
        }
    View: -

    <%: Html.X().GridPanel()
                .Width(400)
                .Height(500)
                .ID("competenciesGridPanel")
                .Store(Html.X().Store()
                .ID("storeId")
                    .Model(Html.X().Model()
                        .Fields(
                                new ModelField("Competency_Mastery_Id", ModelFieldType.Int),
                                new ModelField("Competency_Name", ModelFieldType.String),
                                new ModelField("Mastery_Id", ModelFieldType.Int),
                                new ModelField("Competency_Id", ModelFieldType.Int))
                        .Associations(a =>{a.Add(new HasManyAssociation { Model = "MasteryDTO", Name = "MasteryNames", AssociationKey = "List_Mastery" });
                        })
                    )                    
                     .DataSource(Model))                 
                .ColumnModel(
                    Html.X().Column().ID("cmptncyMasteryId").DataIndex("Competency_Mastery_Id").Hidden(true),
                    Html.X().Column().DataIndex("Competency_Id"),
                    Html.X().Column().DataIndex("Competency_Name"),                
                    Html.X().ComponentColumn()
                    .Flex(1)
                    .DataIndex("Index")
                    .Editor(true)
                    .Component(Html.X().ComboBox()
                        .Flex(1)
                        .DisplayField("Mastery_Name")
                        .ValueField("Mastery_Id")
                        .QueryMode(DataLoadMode.Local)
                        .TriggerAction(TriggerAction.All)
                        .Store(Html.X().Store()
                        .AutoLoad(false)
                        .ModelName("MasteryDTO"))                    
                    )
                    .Listeners(l=>l.Bind.Handler = "cmp.store.add(record.MasteryNames.getRange());")                 
                            )
             
            %>
    Last edited by alscg; Feb 28, 2013 at 9:30 AM.
  4. #4
    Please edit your last post and wrap all code in [CODE] tags.
    Geoffrey McGill
    Founder
  5. #5
    Hi,

    what is 'cmp.store.add'? do i need to write the same or something else in my context?
    'cmp' is Combobox, it is argument is passed to Bind event handler, you don't need to change it

    'record.MasteryNames().getRange()' give error as 'MasteryNames' is not an identified method. If I remove the brackets, it gives error as 'MasteryNames' is undefined.
    You don't need to remove brackets. The problem that you have to use 'Data' in the store instead DataSource (like in my example) because DataSource doesn't serialize extra info (only defined fields)
  6. #6
    I still get the same error after doing change as per your input.
    TypeError: record.MasteryNames is not a function

    With reference to the image attached, [Name="MasteryName"] given in 'Associations' is the one which should be given inside string value for listener right
    Attached Thumbnails Click image for larger version. 

Name:	GridPanel_ComboBox_HasManyAssociations.jpg 
Views:	36 
Size:	65.5 KB 
ID:	5736  
    Last edited by alscg; Feb 28, 2013 at 11:13 AM. Reason: invalid image
  7. #7
    I was wondering if there is a way to get gridpanel row index as I asked for in my first post in this thread.

    Because that is working for me. I hard coded different row indexes and it is filtering the records as per the index.
  8. #8
    Please provide controller and view which we can test without any changes
  9. #9
    I tested with your business object and all works fine for me

    Controller
    public ActionResult Index()
            {
                return View(new List<CompetencyMasteryDTO>() { 
                    new CompetencyMasteryDTO{ Competency_Mastery_Id = 1, Competency_Name = "Name 1",
                        List_Mastery = new List<MasteryDTO>{
                            new MasteryDTO{Mastery_Id = 1, Mastery_Name = "Item 1"}
                        }
                    }
                });
            }
    View
    @model System.Collections.IEnumerable
               
    @using System.Collections.Generic
    
    
    @{
        ViewBag.Title = "ComponentColumn Overview - Ext.NET MVC Examples";
        Layout = "~/Views/Shared/_BaseLayout.cshtml";
    }
    
    
    @section headtag
    {
        
    }
    
    
    @section example
    {    
        @(Html.X().Model()
            .Name("MasteryDTO")
            .Fields(
                new ModelField("Mastery_Name"),
                new ModelField("Mastery_Id", ModelFieldType.Int)
            )
         )
    
    
        @(Html.X().GridPanel()
                .Width(400)
                .Height(500)
                .ID("competenciesGridPanel")
                .Store(Html.X().Store()
                .ID("storeId")
                    .Model(Html.X().Model()
                        .Fields(
                                new ModelField("Competency_Mastery_Id", ModelFieldType.Int),
                                new ModelField("Competency_Name", ModelFieldType.String),
                                new ModelField("Mastery_Id", ModelFieldType.Int),
                                new ModelField("Competency_Id", ModelFieldType.Int))
                        .Associations(a =>{a.Add(new HasManyAssociation { Model = "MasteryDTO", Name = "MasteryNames", AssociationKey = "List_Mastery" });
                        })
                    )                    
                     .Data(Model))                 
                .ColumnModel(
                    Html.X().Column().ID("cmptncyMasteryId").DataIndex("Competency_Mastery_Id").Hidden(true),
                    Html.X().Column().DataIndex("Competency_Id"),
                    Html.X().Column().DataIndex("Competency_Name"),   
                                 
                    Html.X().ComponentColumn()
                    .Flex(1)
                    .DataIndex("Index")
                    .Editor(true)
                    .Component(Html.X().ComboBox()
                        .Flex(1)
                        .DisplayField("Mastery_Name")
                        .ValueField("Mastery_Id")
                        .QueryMode(DataLoadMode.Local)
                        .TriggerAction(TriggerAction.All)
                        .Store(Html.X().Store()
                        .AutoLoad(false)
                        .ModelName("MasteryDTO"))
                    )
                    .Listeners(l=>l.Bind.Handler = "cmp.store.add(record.MasteryNames().getRange());")                 
                            )
        )
    }
  10. #10
    Also please clarify, do you use Razor View or WebForm view? Just I confused with '<%:' syntax
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 18
    Last Post: Mar 13, 2013, 10:40 AM
  2. [CLOSED] Grid Panel with Complex Data model and a ComboBox Editor
    By alscg in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Feb 06, 2013, 11:03 PM
  3. [CLOSED] How to get Cell ID or Row Index in Grid Panel with ComponentColumn
    By Digital.Dynamics in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Aug 14, 2012, 11:58 AM
  4. Replies: 3
    Last Post: Aug 10, 2011, 2:00 PM
  5. [CLOSED] Grid Panel Filter and Sorting futures for Large data
    By speedstepmem3 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: May 16, 2010, 7:50 PM

Posting Permissions