Dec 01, 2010, 4:28 PM
[CLOSED] Adding Items to Store Client-side, want to retrieve server side
Hi, I have a combo box where users select items.
I have a multiselect that lists all of the selected items.
The multi-select is bound to a simple store.
When the user submits to the server, I want to get at the data that has been added to the store...
The Item collection of the multiselect is empty...and I can't see to find where to obtain the data in the store..
Do I need to commit or save the store? That doesn't seem to work either...
I have a multiselect that lists all of the selected items.
The multi-select is bound to a simple store.
When the user submits to the server, I want to get at the data that has been added to the store...
The Item collection of the multiselect is empty...and I can't see to find where to obtain the data in the store..
Do I need to commit or save the store? That doesn't seem to work either...
<ext:Store ID="attendeesSelected" runat="server" AutoDataBind="true" AutoLoad="true" >
<Reader>
<ext:JsonReader>
<Fields>
<ext:RecordField Name="text" Type="String" />
<ext:RecordField Name="value" Type="String" />
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
The combo box lets users search for people <ext:ComboBox ID="ComboBox1" runat="server" AllowBlank="true" BlankText="Type to search"
EmptyText="Attendees" StyleSpec="background:#fff url('../../extnet/icons/magnifier.png') no-repeat right;"
StoreID="contactSearch" DisplayField="Name" ValueField="Url" TypeAhead="false"
LoadingText="Searching..." Width="250" Height="200" HideTrigger="true" ItemSelector="div.search-item"
MinChars="1">
<Template ID="Template1" runat="server">
<Html>
<tpl for=".">
<div class="search-item">
<img src="../../images/{Image}" />{Name}
</div></tpl>
</Html>
</Template>
<Listeners>
<Select Handler=" addMultiSelectNew(this,#{msAttendees},#{attendeesSelected},#{hidAttendeeIds}); if(#{contactSearch}.data.length>1) #{ComboBox1}.expand();#{ComboBox1}.reset(); " />
</Listeners>
</ext:ComboBox>
The multi select just displays the selected items..<ext:MultiSelect ID="msAttendees" StoreID="attendeesSelected" DisplayField="text"
ValueField="value" runat="server" Width="250" AutoHeight="true" MaxHeight="150"
SortField="text" AllowDuplicates="false" KeepSelectionOnClick="WithCtrlKey">
<Items>
</Items>
</ext:MultiSelect>
The magic happens in my javascript method that adds text/value to the store from the selected combobox:
function addMultiSelectNew(t, multiSelect, store, hiddenIds) {
try {
var multi = multiSelect;
var entityTypeId;
var entityId;
var displayField = multi.displayField;
var valueField = multi.valueField;
var f = store.recordType.prototype.fields, dv = [];
for (var i = 0; i < f.length; i++) {
dv[f.items[i].name] = f.items[i].defaultValue;
}
var record = new store.recordType(dv);
record.set(displayField, t.getText());
record.set(valueField, t.getValue());
store.add([record]);
}
catch (eer) {
}
}
Last edited by Daniil; Dec 03, 2010 at 10:49 AM.
Reason: [CLOSED]