This is a migrated thread and some comments may be shown as answers.

Two grid have the same field

3 Answers 109 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gusev
Top achievements
Rank 1
Gusev asked on 26 Apr 2013, 01:02 PM
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!

3 Answers, 1 is accepted

Sort by
0
Accepted
Petur Subev
Telerik team
answered on 30 Apr 2013, 07:26 AM
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!
0
Gusev
Top achievements
Rank 1
answered on 30 Apr 2013, 08:55 AM
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.
0
Petur Subev
Telerik team
answered on 02 May 2013, 06:58 AM
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!
Tags
Grid
Asked by
Gusev
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Gusev
Top achievements
Rank 1
Share this question
or