[CLOSED] Databind on store for itemselector doubles the contents

  1. #1

    [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.

            <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]
  2. #2
    Hi Hans,

    Reproduced. Thank you for the report. We are investigating.
  3. #3
    Fixed in SVN
  4. #4
    Great! It works fine now.
    Thanks a lot!

    Hans
  5. #5
    Quote Originally Posted by HansWapenaar View Post
    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!
  6. #6
    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.

Similar Threads

  1. [CLOSED] DataBind store to a dictionary?
    By jmcantrell in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: May 17, 2013, 1:04 AM
  2. Store DataBind in DirectEvents
    By threewonders in forum 1.x Help
    Replies: 1
    Last Post: Nov 03, 2011, 10:04 AM
  3. [1.0] Store.LoadData vs DataBind
    By Kam in forum 1.x Help
    Replies: 1
    Last Post: Apr 19, 2011, 11:00 AM
  4. fasten databind to store
    By Birgit in forum 1.x Help
    Replies: 0
    Last Post: Sep 15, 2010, 7:04 AM
  5. [CLOSED] Extracting store contents
    By peterdiplaros in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: Dec 24, 2008, 12:25 PM

Posting Permissions