View Full Version : Select Ext.ux.form.MultiSelect entries based on XmlReader fields

5 May 2010, 12:03 AM

I have a form with an Ext.ux.form.MultiSelect element. This UI control retrieve the available entries from an XMLStore. No I am trying to preselect some entries in the MultiSelect during form load (XMLReader).

I can select the elements with setValue('3,4'). But how can I retrieve this selection value from the XMLReader?

The XMLReader retreive the following XML:

<?xml version="1.0" ?><message success="true"><SenderAddress><id>30</id><address>hericks</address><account_list>5,6,9</account_list></SenderAddress></message>

Thanks for your help.


p.s. I hope the posted code is not to long. But I am not sure, which part of the code is required to explain the problem.

// create a data store to hold all available addresses for the
// multi selection box
var accounts_store = new Ext.data.XmlStore({
autoDestroy: true,
storeId: 'myStore',
url: '/mail/mailaccount/?ajax=1',

root: 'MailAccounts',
record: 'MailAccount',
idPath: 'id',
totalRecords: '@TotalResults',
totalProperty: 'TotalResults',
remoteSort: true,

fields: [
{name: 'id', mapping: 'id'},
{name: 'user_name', mapping: 'user_name'},
{name: 'status'},
{name: 'quota_status'},
{name: 'lastlogin'},
{name: 'senderaddresses'}

listeners: {
load: {
fn: function(){
fs.getForm().load({url: '/mail/senderaddress/edit/30/?load=1', waitMsg: 'Loading sender address'});
/* TODO: preselect the members */
//x = fs.getForm();

var fs = new Ext.FormPanel({
frame: true,
labelAlign: 'left',
labelWidth: 85,
waitMsgTarget: true,

// configure how to read the XML Data
reader : new Ext.data.XmlReader({
record : 'SenderAddress',
success: '@success'
}, [
{name: 'id', mapping: 'id'},
{name: 'address', mapping: 'address', convert: mailaddress_to_leftpart},
{name: 'account_list', mapping: '/account_list'} //, convert: status_to_checkbox},

// reusable eror reader class defined at the end of this file
errorReader: new Ext.form.XmlErrorReader(),

items: [
new Ext.form.FieldSet({
autoHeight: true,
defaultType: 'textfield',
items: [{
fieldLabel: 'Sender Address',
emptyText: 'new sender address',
name: 'address',
width: 250,
allowBlank: false,
new Ext.ux.form.MultiSelect({
fieldLabel: 'Allowed senders',
name: 'accounts',
width: 250,
height: 300,
minSelections: 1,
mode: 'remote',
store: accounts_store,
displayField: 'user_name',
valueField: 'id',
ddReorder: false,
allowBlank: false



// explicit add
var submit = fs.addButton({
text: 'Update',
disabled: false,
handler: function(){
url: '/mail/senderaddress/edit/30/',
waitMsg: 'Updating sender address...',
submitEmptyText: true,

success: function() {
var redirect = '/mail/senderaddress/';
window.location = redirect;
failure: function(form, action) {
title: 'Icon Support',
msg: "Unable to store sender address",
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.ERROR