PDA

View Full Version : [CLOSED] GridPanel with '.' in DataIndex



UnifyEducation
Nov 15, 2013, 9:17 AM
Hi,

I am working with GridPanel, and the Model is generated dynamically, so it changes each time. I have observed that it does not work when there is '.' character in the model. Can you tell me how to solve this problem in the case that I cannot change me ModelField name
Here is my test code:

@model dynamic

@{
Layout = null;
}
@(Html.X().ResourceManager())
@(Html.X().GridPanel()
.Store(Html.X().Store()
.Model(Html.X().Model()
.Fields(f =>
{
f.Add(Html.X().ModelField().Name("ITEM.1"));
f.Add(Html.X().ModelField().Name("ITEM.2"));
})))
.ColumnModel(c =>
{
c.Add(Html.X().Column().DataIndex("ITEM.1"));
c.Add(Html.X().Column().DataIndex("ITEM.2"));
})

)

Daniil
Nov 15, 2013, 11:14 AM
Hi @UnifyEducation,

Please clarify what is meant by "ITEM.1"? I don't think a property's name can contain a dot. What kind of data do you bind to the Store?

UnifyEducation
Nov 15, 2013, 11:40 AM
Hi @UnifyEducation,

Please clarify what is meant by "ITEM.1"? I don't think a property's name can contain a dot. What kind of data do you bind to the Store?

Hi,
I use a DataTable for binding to the Store.



@using System.Data
@model dynamic

@{
Layout = null;
var data_table = new DataTable();
data_table.Columns.Add(new DataColumn("ITEM.1"));
data_table.Columns.Add(new DataColumn("ITEM.2"));
var row1 = data_table.NewRow();
row1["ITEM.1"] = "row1-item1";
row1["ITEM.2"] = "row1-item2";
data_table.Rows.Add(row1);
var row2 = data_table.NewRow();
row2["ITEM.1"] = "row2-item1";
row2["ITEM.2"] = "row2-item2";
data_table.Rows.Add(row2);
}
@(Html.X().ResourceManager())
@(Html.X().GridPanel()
.Store(Html.X().Store().DataSource(data_table)
.Model(Html.X().Model()
.Fields(f =>
{
f.Add(Html.X().ModelField().Name("ITEM.1"));
f.Add(Html.X().ModelField().Name("ITEM.2"));
})))
.ColumnModel(c =>
{
c.Add(Html.X().Column().DataIndex("ITEM.1"));
c.Add(Html.X().Column().DataIndex("ITEM.2"));
})

)

Vladimir
Nov 15, 2013, 12:16 PM
Try to add JsonReader with UseSimpleAccessors(true)