PDA

View Full Version : Item selector Help in extjs 2.2.1



suganyazen
30 Mar 2011, 9:50 PM
Hi,

I am using itemselector element in a form.

I am getting output from store correctly.

But it is not populating in itemselector.

I have pasted my code below.

var dsLocalizaciones = new Ext.data.Store({
url: 'php/report_fields.php?act=select',
listeners: {
load: function(dsLocalizaciones, records, options) {
alert('hi');
alert("Store record[0] value is " + records[0].get('fieldname'));
}
},
reader: new Ext.data.JsonReader({
id: 'fielddisplays',
root: 'results',
remoteSort:true,
totalProperty: 'total'
}, [
{name: 'fieldname', mapping: 'fieldname'},
{name: 'fieldvalue', mapping: 'fieldvalue'}
])
});

dsLocalizaciones.load();
alert(dsLocalizaciones.getTotalCount());
var store = new Ext.data.SimpleStore({
fields: [
{name: 'fieldname', mapping: 'fieldname'},
{name: 'fieldvalue', mapping: 'fieldvalue'}
]
});



/*
* Ext.ux.ItemSelector Example Code
*/

var formItemSelector = new Ext.form.FormPanel({
labelWidth: 75,
width:700,
items:[{
xtype:"itemselector",
name:"itemselector",
fieldLabel:"ItemSelector",
/*dataFields:["code", "desc"],
fromData:[[123,"One Hundred Twenty Three"],
["1", "One"], ["2", "Two"], ["3", "Three"], ["4", "Four"], ["5", "Five"],
["6", "Six"], ["7", "Seven"], ["8", "Eight"], ["9", "Nine"]],
toData:[["10", "Ten"]],*/
fromStore: dsLocalizaciones,
toStore: store,
msWidth:250,
msHeight:200,
valueField:"code",
displayField:"desc",
//imagePath:"ext-ux/multiselect",
//switchToFrom:true,
toLegend:"Selected",
fromLegend:"Available",
toTBar:[{
text:"Clear",
handler:function(){
var i=formItemSelector.getForm().findField("itemselector");
i.reset.call(i);
}
}]
}],
buttons:[{
text:"Get Value",
handler: function(){
alert(formItemSelector.getForm().getValues(true));
}
},{
text:"Mark Invalid",
handler: function(){
formItemSelector.getForm().findField("itemselector").markInvalid("Invalid");
}
}]
});
formItemSelector.render("form-ct-itemselector");


});
</head>

<body style="margin:20px;">

<b>Ext.ux.Multiselect/ItemSelector</b>, <i>Version 3.0</i>


<br><p><br><p>
<div style="width:800px;">
<div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div>
<div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc">
<div id="form-ct-itemselector"></div>

</div></div></div>
<div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div>
</div>
</body>

</html>

I am checking with this for more than two days.

Please help me

Thanks & Regards,
Suganya

suganyazen
30 Mar 2011, 11:18 PM
Hi,

I have solved that issue.

Json store result is not in correct format.

Thanks
R.Suganya