PDA

View Full Version : [CLOSED] Databind on store for itemselector doubles the contents



HansWapenaar
Jan 29, 2014, 3:09 PM
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.



<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

Daniil
Jan 29, 2014, 3:59 PM
Hi Hans,

Reproduced. Thank you for the report. We are investigating.

Vladimir
Jan 29, 2014, 9:57 PM
Fixed in SVN

HansWapenaar
Jan 29, 2014, 10:23 PM
Great! It works fine now.
Thanks a lot!

Hans

talb
Feb 14, 2014, 12:34 PM
Great! It works fine now.
Thanks a lot!

Hans

Sorry about posting on a solved topic, but I had the same issue with ItemSelector on version 2.4.0.30091.
After spending some time on it, i finally got it working using:

#{itemSelector}.removeAll();
#{itemSelector}.reset();

Thanks!

Daniil
Feb 14, 2014, 12:43 PM
Hi @talb,

Welcome to the Ext.NET forums and thank you for sharing the solution!


Sorry about posting on a solved topic

That is good if a new info is totally related to the topic.