Sep 05, 2009, 8:52 AM
Exception while saving grid - System.IndexOutOfRangeException: Index was outside the bounds of the array. at Coolite.Ext.Web.RecordsToXmlConverter.DeserializeV alue
Hi,
In my grid I am taking input as range. Eg., 1-100 in a TextField. While saving this in the database it is getting saved as 100 rows. The problem i am facing is - it is getting saved in database correctly but getting following exception on the
clientside.
Can you please give me some clue to troubleshoot this issue.
In my grid I am taking input as range. Eg., 1-100 in a TextField. While saving this in the database it is getting saved as 100 rows. The problem i am facing is - it is getting saved in database correctly but getting following exception on the
clientside.
<style type="text/css">body{border:0;margin:0;padding:3px;height:98%;cursor:text;}</style>System.Exception: Index was outside the bounds of the array. --->
System.IndexOutOfRangeException: Index was outside the bounds of the array. at
Coolite.Ext.Web.RecordsToXmlConverter.DeserializeValue(JsonReader reader,
XmlDocument document, XmlNamespaceManager manager, String propertyName, XmlNode
currentNode) at Coolite.Ext.Web.RecordsToXmlConverter.DeserializeNode(JsonReader
reader, XmlDocument document, XmlNamespaceManager manager, XmlNode currentNode)
at Coolite.Ext.Web.RecordsToXmlConverter.ReadJson(JsonReader reader, Type
objectType) at Newtonsoft.Json.JsonSerializer.CreateObject(JsonReader reader,
Type objectType, Object existingValue, JsonConverter memberConverter) at
Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type,
JsonSerializerSettings settings) at
Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type,
JsonConverter[] converters) at Coolite.Ext.Web.StoreDataHandler.get_XmlData() at
Coolite.Ext.Web.Store.MakeChanges() at Coolite.Ext.Web.Store.DoSaving(String
jsonData, XmlNode callbackParameters) --- End of inner exception stack trace ---
at Coolite.Ext.Web.Store.DoSaving(String jsonData, XmlNode callbackParameters)
at Coolite.Ext.Web.Store.RaiseAjaxPostBackEvent(String eventArgument)
My Store defination goes as follows:<ext:Store ID="storeOpeningStock" runat="server" OnBeforeStoreChanged="storeOpeningStock_BeforeChange" RefreshAfterSaving="None" AutoLoad="false" >
<Reader>
<ext:JsonReader ReaderID="StkId">
<Fields>
<ext:RecordField Name="MobileNumber" />
<ext:RecordField Name="IMSI" />
<ext:RecordField Name="Quantity" />
<ext:RecordField Name="ExpiryDate" Type="Date"/>
<ext:RecordField Name="OpeningStockDate" Type="Date"/>
<ext:RecordField Name="PurchasePrice" Type="Float" DefaultValue="0"/>
<ext:RecordField Name="StkId" />
</Fields>
</ext:JsonReader>
</Reader>
<Listeners>
<SaveException Handler="Ext.Msg.alert('Status','save execption.')" />
<CommitDone Handler="Ext.Msg.alert('Status','Data Saved Successfully.')" />
<CommitFailed Handler="Ext.Msg.alert('Status','Commit Failed.')" />
<LoadException Handler="Ext.Msg.alert('Status','Error loading data.')" />
</Listeners>
</ext:Store>
Grid as follows:<ext:GridPanel ID="gridSIM" runat="server" MaskDisabled="false" AutoExpandColumn="ItemDescription" StoreID="storeItems" Height="100" ClicksToEdit="1" StripeRows="true">
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:RowNumbererColumn />
<ext:Column Sortable="false" MenuDisabled="true" ColumnID="ItemId" DataIndex="ItemId" Header="Item Id" Hidden="true">
<Editor>
<ext:TextField ID="txtItemId" runat="server" AllowBlank="false" MsgTarget="Under"/>
</Editor>
</ext:Column>
<ext:Column Sortable="false" MenuDisabled="true" ColumnID="ItemCode" DataIndex="ItemCode" Header="Item Code">
<Editor>
<ext:TextField ID="txtItemCode" runat="server" AllowBlank="false" MsgTarget="Under"/>
</Editor>
</ext:Column>
<ext:Column Sortable="false" MenuDisabled="true" DataIndex="ItemName" Header="Item Name">
<Editor>
<ext:TextField ID="txtItemName" runat="server" AllowBlank="false" MsgTarget="Under" />
</Editor>
</ext:Column>
<ext:Column Sortable="false" MenuDisabled="true" DataIndex="ItemDescription" ColumnID="ItemDescription" Header="Description" Width="200">
<Editor>
<ext:TextField ID="txtItemDesc" runat="server"/>
</Editor>
</ext:Column>
<ext:ImageCommandColumn Width="210">
<Commands>
<ext:ImageCommand Style="azimuth:center" CommandName="Edit" Icon="NoteEdit" Text="Opening Stock">
<ToolTip Text="View/Edit Opening Stock" />
</ext:ImageCommand>
</Commands>
</ext:ImageCommandColumn>
</Columns>
</ColumnModel>
<AjaxEvents>
<Command OnEvent="onCommand">
<EventMask ShowMask="true" Target="This"/>
</Command>
</AjaxEvents>
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true"/>
</SelectionModel>
<LoadMask ShowMask="true" />
<SaveMask ShowMask="true" />
</ext:GridPanel>
Code behind as follows:protected void storeOpeningStock_BeforeChange(object sender, BeforeStoreChangedEventArgs e)
{
ChangeRecords<SIMVO> data = e.DataHandler.ObjectData<SIMVO>();
//delete records removed
List<ItemVO> deleteList = new List<ItemVO>();
ItemVO deleteItemVO = new ItemVO();
deleteItemVO.ItemType = ItemVO.ITEMTYPE.SIM;
deleteItemVO.ItemId = Convert.ToInt64(txtSelectedItemId.Text);
foreach (SIMVO simVO in data.Deleted)
{
deleteItemVO.SIMList.Add(simVO);
}
if (deleteItemVO.SIMList.Count > 0)
{
deleteList.Add(deleteItemVO);
businessServiceFactory.getStockService().removeStock(deleteList, DateTime.Now, ItemVO.STOCKOPERATION.OPENING);
}
//save records updated
List<ItemVO> updateList = new List<ItemVO>();
ItemVO updateItemVO = new ItemVO();
updateItemVO.ItemType = ItemVO.ITEMTYPE.SIM;
updateItemVO.ItemId = Convert.ToInt64(txtSelectedItemId.Text);
foreach (SIMVO simVO in data.Updated)
{
updateItemVO.SIMList.Add(simVO);
}
if (updateItemVO.SIMList.Count > 0)
{
updateList.Add(updateItemVO);
businessServiceFactory.getStockService().updateStock(updateList, DateTime.Now, ItemVO.STOCKOPERATION.OPENING);
}
//save record inserted
List<ItemVO> insertList = new List<ItemVO>();
ItemVO insertItemVO = new ItemVO();
insertItemVO.ItemType = ItemVO.ITEMTYPE.SIM;
insertItemVO.ItemId = Convert.ToInt64(txtSelectedItemId.Text);
foreach (SIMVO simVO in data.Created)
{
insertItemVO.SIMList.Add(simVO);
}
if (insertItemVO.SIMList.Count > 0)
{
insertList.Add(insertItemVO);
businessServiceFactory.getStockService().addOpeningStock(insertList);
}
}
Additionalty though i have CommitFailed listener in the store, default exception window is appearing along with message egistered for CommitFailed.Can you please give me some clue to troubleshoot this issue.