Jan 29, 2014, 2:09 PM
[CLOSED] Databind on store for itemselector doubles the contents
Hello,
I'using an ItemSelector and fill it with a datasource (mySQL table).
This works fine, but it must be possible that the options in the itemselector are refreshed. (in other page user can add options).
When a databind on the store of the itemselector is implemented it looks like the new data is just added to the old data. So the amount of records is doubled. The old data is not removed.
Error message:
0x800a138f - Runtime-fout JavaScript: Kan de eigenschap internalId van een niet-gedefinieerde verwijzing of een verwijzing naar een lege waarde niet ophalen>
stack trace:
updateIndexes [WebResource.axd] Line 18 Script
onAdd [WebResource.axd] Line 18 Script
fire [WebResource.axd] Line 18 Script
continueFireEvent [WebResource.axd] Line 27 Script
Anonymous function [WebResource.axd] Line 18 Script
fireEventArgs [WebResource.axd] Line 25 Script
Anonymous function [WebResource.axd] Line 18 Script
fireEvent [WebResource.axd] Line 25 Script
Anonymous function [WebResource.axd] Line 18 Script
insert [WebResource.axd] Line 18 Script
add [WebResource.axd] Line 18 Script
populateFromStore [WebResource.axd] Line 49 Script
Error location in javascript:
this.onUpdate(this.dataSource,this.dataSource.getA t(a))},updateIndexes:function(e,d){
var b=this.all.elements,a=this.getViewRange(),c;e=e||0 ;d=d||((d===0)?0:(b.length-1));
for(c=e;c<=d;c++){b[c].viewIndex=c;
b[c].viewRecordId=a[c].internalId; // THIS PART GENERATES THE ERROR
The contents of b has the 'double' records after the second databind.
Any idea what i'm missing?
Hans Wapenaar
I'using an ItemSelector and fill it with a datasource (mySQL table).
This works fine, but it must be possible that the options in the itemselector are refreshed. (in other page user can add options).
When a databind on the store of the itemselector is implemented it looks like the new data is just added to the old data. So the amount of records is doubled. The old data is not removed.
<ext:Window
ID="DetailsWindowEvents"
runat="server"
Icon="Group"
Title="Events"
Width="360"
Height="345" MinHeight="345"
AutoShow="false"
Modal="true"
Hidden="true"
CloseAction="Hide"
Layout="BorderLayout" >
<Items>
<ext:FormPanel ID="FormPanelWindowEvents"
runat="server"
Title="ItemSelector Test"
Width="350" Header="false"
BodyPadding="10"
Height="300"
Layout="FitLayout">
<Items>
<ext:ItemSelector
ID="ItemSelectorEvents"
runat="server"
AllowBlank="false"
MsgTarget="Side"
FromTitle="Available"
ToTitle="Selected"
DisplayField="textname"
ValueField="valueid"
DataIndex="valueid"
TypeAhead="true"
Reorderable="false"
Width="350" MaxWidth="350" >
<Store>
<ext:Store ID="StoreItemSelectorEvents" runat="server" AutoDataBind="false" >
<Model>
<ext:Model ID="ModelItemSelectorEvents" runat="server" IDProperty="valueid">
<Fields>
<ext:ModelField Name="valueid" Type="String" />
<ext:ModelField Name="textname" Type="String" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
</ext:ItemSelector>
</Items>
<DockedItems>
<ext:Toolbar ID="ToolbarItemSelectorEvents" runat="server" Dock="Bottom" UI="footer">
<Defaults>
<ext:Parameter Name="minWidth" Value="75" />
</Defaults>
<Items>
<ext:ToolbarFill />
<ext:Button ID="btnItemSelectorEventsSave" runat="server" Text="Save" Icon="Disk" OnDirectClick="btnItemSelectorSave_onClick" />
<ext:Button ID="btnItemSelectorEventsCancel" runat="server" Text="Cancel" Icon="Cancel" OnDirectClick="btnItemSelectorCancel_onClick" />
</Items>
</ext:Toolbar>
</DockedItems>
</ext:FormPanel>
</Items>
</ext:Window>
Resetting the options is done in the following server side code: Dim selected(0) As String ' is filled with selected id's
' ItemSelectorEvents.Clear()
' ItemSelectorEvents.Reset()
' ItemSelectorEvents.ResetOriginalValue()
SqlDataSourceItemSelectorEvents.SelectCommand = "SELECT event_id as valueid, textname FROM events;"
ItemSelectorEvents.GetStore.DataSource = SqlDataSourceItemSelectorEvents
ItemSelectorEvents.GetStore.DataBind()
ItemSelectorEvents.SetValue(selected)
DetailsWindowEvents.Show()
Error message:
0x800a138f - Runtime-fout JavaScript: Kan de eigenschap internalId van een niet-gedefinieerde verwijzing of een verwijzing naar een lege waarde niet ophalen>
stack trace:
updateIndexes [WebResource.axd] Line 18 Script
onAdd [WebResource.axd] Line 18 Script
fire [WebResource.axd] Line 18 Script
continueFireEvent [WebResource.axd] Line 27 Script
Anonymous function [WebResource.axd] Line 18 Script
fireEventArgs [WebResource.axd] Line 25 Script
Anonymous function [WebResource.axd] Line 18 Script
fireEvent [WebResource.axd] Line 25 Script
Anonymous function [WebResource.axd] Line 18 Script
insert [WebResource.axd] Line 18 Script
add [WebResource.axd] Line 18 Script
populateFromStore [WebResource.axd] Line 49 Script
Error location in javascript:
this.onUpdate(this.dataSource,this.dataSource.getA t(a))},updateIndexes:function(e,d){
var b=this.all.elements,a=this.getViewRange(),c;e=e||0 ;d=d||((d===0)?0:(b.length-1));
for(c=e;c<=d;c++){b[c].viewIndex=c;
b[c].viewRecordId=a[c].internalId; // THIS PART GENERATES THE ERROR
The contents of b has the 'double' records after the second databind.
Any idea what i'm missing?
Hans Wapenaar
Last edited by Daniil; Jan 30, 2014 at 3:05 AM.
Reason: [CLOSED]