Two grid have the same field

4 posts, 1 answers
  1. Gusev
    Gusev avatar
    83 posts
    Member since:
    Dec 2012

    Posted 26 Apr 2013 Link to this post

    Hello!
    I have 2 grid!
    First grid has field: Volume with Uihint ["Decimal"]
    Second grid has field: Volume Uihint ["Decimal"]
    I have this:

    my view:
    // something
     @(Html.Kendo().Grid<type1>()
                    .Name("typ1")
                    .ToolBar(toolBar => toolBar.Create())
                    .Columns(columns =>
                    {
                                // other
                                columns.Bound(o => o.Volume);
                                // other
                    }
    // other
    )
     
    <br/ >
     
    // something
     @(Html.Kendo().Grid<type2>()
                    .Name("typ2")
                    .ToolBar(toolBar => toolBar.Create())
                    .Columns(columns =>
                    {
                                // other
                                columns.Bound(o => o.Volume);
                                // other
                    }
    // other
    )
    If I use bind Combobox or KendoNumbericTextbox for my field: Volume(in first grid and secondgrid)
    And simultaneously edit the element in the first and second grid
    I see this: 1.png

    I believe that this is because jQuery will return the first element in the DOM and initialize NumericTextBox from it.

    how can I get around this problem by using Kendo?
    I don't want create another field for any coincidence, because I have 10+ coincidences 
    Please help!
  2. Answer
    Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 30 Apr 2013 Link to this post

    Hello Gusev,

    Basically what is important for the Grid to update the value is not the name of the widget but the binding assigned to it (which ofcourse is automatically generated based on the Model).
    You can try to change the generated ID (thus there wont be name collisions) and see if it continues to update the record as expected.

    e.g.

    @(Html.Kendo().DateTimePickerFor(m => m).HtmlAttributes(new { id= Guid.NewGuid().ToString()}))


    Kind Regards,
    Petur Subev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Gusev
    Gusev avatar
    83 posts
    Member since:
    Dec 2012

    Posted 30 Apr 2013 Link to this post

    Hello!
    But if I have 
    1 field with UIHint: Decimal
    2 field with UIHint: Integer
    3 field with UIHint: DateTimePicker
    4 field with UIHint: CustomListWithCombobox
    5 field with UIHint: CustomListWithCombobox2
    6 field with UIHint: CustomListWithCombobox3
    .....and ..... all  fields in one View in different grid
    Can I use ".HtmlAttributes(new { id= Guid.NewGuid().ToString()"  in each EditorTemplates?
    How here :
    @model int
                
    @(Html.Kendo().DropDownListFor(x => x)
        .DataTextField("Description")
        .DataValueField("Id")
        .DataSource(databinding => databinding
            .Read(read => read
            .Action(" ", "")))
        .OptionLabel("select this")
        .HtmlAttributes(new { id = Guid.NewGuid().ToString() })
    )
    or here:
    @model int
     
    @(Html.Kendo().IntegerTextBoxFor(m => m)
          .HtmlAttributes(new { style = "width:70px" })
          .Min(0)
          .DecreaseButtonTitle("-1")
          .IncreaseButtonTitle("+1")
          .HtmlAttributes(new { id = Guid.NewGuid().ToString() })
    )
    If I can use this ".HtmlAttributes(new { id= Guid.NewGuid().ToString()" in every  EditorTemplates  and this don't cause error ,this is very cool.
  4. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 02 May 2013 Link to this post

    Hello Gusev,

    Did you face any difficulties if you go this why, by generating the IDs randomly? I tried it on my side and inside of the Grid this is working as expected.

    The limitation I see is that you cannot easily get reference to the client objects since you do not know the IDs and you need to do some DOM traversal with jQuery to find them.

    Let me know if further questions arise.

    Kind Regards,
    Petur Subev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top