Hello,
I have a problem when calling igGrid("Databind') method on igGrid to refresh Data after having add a new record.
Here is the configuration of igGrid :
<%= Html.Infragistics().Grid(Model.ListeSites).ID("Sites").DataSourceUrl(Url.Action("GetListe")).AutoCommit(true).PrimaryKey("Site").AutoGenerateColumns(false).EnableHoverStyles(false).Columns(column => { column.For(x => x.Site).HeaderText("Site").Width("45"); column.For(x => x.Description).HeaderText("Description").Width("150"); column.For(x => x.Nom).HeaderText("Nom").Width("100"); column.For(x => x.Adresse1).HeaderText("Adresse 1").Width("100"); column.For(x => x.Adresse2).HeaderText("Adresse 2").Width("100"); column.For(x => x.CodePostal).HeaderText("Code postal").Width("100"); column.For(x => x.Ville).HeaderText("Ville").Width("90"); column.For(x => x.Contact).HeaderText("Contact").Width("90"); column.For(x => x.Telephone).HeaderText("Téléphone").Width("90"); column.For(x => x.Siret).HeaderText("Siret").Width("90"); }) .Features(features => { features.Paging().Type(OpType.Local).PageSize(20); features.Sorting().Mode(SortingMode.Single); if (User.IsInRole(((int)Andra.PriscaND.Business.Model.RoleName.Administrateur).ToString())) { features.Updating() .EnableAddRow(true) .EnableDeleteRow(true) .EditMode(GridEditMode.Row) .ColumnSettings(settings => { settings.ColumnSetting().ColumnKey("Site").ReadOnly(false).EditorType(ColumnEditorType.Text).Required(true).Validation(true) .EditorOptions(@"validatorOptions: {requiredMessage: 'Site obligatoire'}, maxLength:3"); settings.ColumnSetting().ColumnKey("Description").EditorType(ColumnEditorType.Text).Required(true) //.EditorOptions(@"validatorOptions: {errorLabel: 'GridValidation', onChange: true}"); .EditorOptions(@"validatorOptions: {requiredMessage: 'Description obligatoire'}, maxLength:250"); settings.ColumnSetting().ColumnKey("Nom").ReadOnly(false).EditorOptions("maxLength:50"); settings.ColumnSetting().ColumnKey("Adresse1").ReadOnly(false).EditorOptions("maxLength:50"); settings.ColumnSetting().ColumnKey("Adresse2").ReadOnly(false).EditorOptions("maxLength:50"); settings.ColumnSetting().ColumnKey("CodePostal").ReadOnly(false).EditorOptions("maxLength:20"); settings.ColumnSetting().ColumnKey("Ville").ReadOnly(false).EditorOptions("maxLength:50"); settings.ColumnSetting().ColumnKey("Contact").ReadOnly(false).EditorOptions("maxLength:50"); settings.ColumnSetting().ColumnKey("Telephone").ReadOnly(false).EditorOptions("maxLength:20"); settings.ColumnSetting().ColumnKey("Siret").ReadOnly(false).EditorOptions("maxLength:14"); }); } }).DataBind().Render()
Then the JS code that generates error :
$("#Sites").igGrid("dataBind");
Here is the error from Firefox :
Error: There was an error parsing/evaluating the JSON string: JSON.parse: unexpected characterhttp://localhost:49944/Scripts/infragistics.jsLine 51
And loading panel remains turning around and nothing more happens.
Tank's by advance.
Regards,
Hardis
Hi Hardis,
Great! I'm glad that your issue is resolved.
Please, note that this workaround works only when you have local paging and sorting.
In remote paging and sorting scenario GridDataSourceAction is handling those operations behind the scenes so it is mandatory.
Best regards,
Martin Pavlov
Infragistics, Inc.
This works great !
Notice that GridDataSourceActionAttribut shall not annotate the GetList method.
Thank you very much for your help.
From what I see in the Firefox network data allSites.GetAllSites() data is not serialized at all. However if that is the case you should get an error on the server side. In Firebug you can check the Net tab -> XHR -> Response or Net tab -> XHR -> HTML. Usually there you'll see the yellow screen of death.
GridDataSourceAction is using JavaScriptSerializer behind the scenes to serialize the data. As an alternative you can try to serialize the data by using action which returns JsonResult.
Here is an example code:
Note: You should also modify your grid initialization code to include the method : .ResponseDataKey(""). This is because the Json is returned as an array so there is not response data key.
Try it and tell me if it works.
Thank you for this update and detaisl. I am testing this issue and will follow-up youw with an update.
Version of Infragistics : 3.12.1.1010
Net advantage 2012.1
Version of JQuery : 1.5.1
Version of JQuery UI : 1.8.1
Thank's for your help.
Regards