PDA

View Full Version : [CLOSED] SelectedItem for MultiSelect Ext 2.5.2 Webforms



LAEUser
Jan 26, 2015, 4:34 PM
I am having trouble setting a selected item for a multiselect. This is from code behind.



MultiSelect msParam = new MultiSelect();
msParam.ID = "paramid__40";
msParam.FieldLabel = "mytitle"
msParam.MultiSelect = true;
...
store created and loaded
---
msParam.SelectedItems.Clear();
msParam.SelectedItems.Add(new Ext.Net.ListItem { Text = "Board President", Value = "Board President" });
msParam.UpdateSelectedItems();



Here is the generated script on the page. you can see it add the selecteditems. you can see on the image it does not. any suggestions. thanks


<script type="text/javascript">
//<![CDATA[
Ext.net.ResourceMgr.init({id:"ScriptManager1",aspForm:"theForm",theme:"gray",icons:[{name:"ReportGo",url:"/WebResource.axd?d=1IH1P8W6qJrIcCjztWRe0zWV487m5f-dqaY2ADT-oPuArB1dL3KX1uRJp-CMxjqR3dMu3lixqQeQ_MXCwXJ6o5ZMSQ3PnJcA1syOj_WcZyRK GQOfc_wiA-78x22WZoDB1GEjYQ2&amp;t=635476769949990000"},{name:"Cancel",url:"/WebResource.axd?d=pMMYDmRNkggusLes_mX6xgQ55wYu4SO-hFxNRhXlcOSLV_i-EvMEMZj_X8lhCI-e22-wAlABFX-OeZGSFxdzKyw6nDK0gxL_z8Mz5s1FgtXBS7Tw0&amp;t=635476769 949990000"}]});Ext.onReady(function(){Ext.create("Ext.panel.Panel",{id:"extPnlCreateReportParams",border:false,renderTo:"App.extPnlCreateReportParams_Container",items:[{id:"extFrmPnlParamsDetails",border:false,xtype:"form",items:[{id:"extFldSetParams",padding:"10 10 20 10",xtype:"fieldset",defaults:{"msgTarget":"under","labelWidth":115,"labelCls":"createReportParamLabel"},items:[{id:"paramid_41",width:400,xtype:"combobox",fieldLabel:"Program",invalidCls:"error",indicatorText:"*",indicatorCls:"red-text",allowBlank:false,blankText:"Program is required",editable:false,selectedItems:[{text:"All",value:"BO','PL','WC','NO"}],forceSelection:true,queryMode:"local",valueField:"value",store:{model:Ext.define("model__paramid_41", {extend: "Ext.data.Model", fields:[{name:"text",type:"string"},{name:"value",type:"string"}],idProperty:"value" }),storeId:"store__paramid_41",autoLoad:true,proxy:{data:[{"text":"All","value":"BO','PL','WC','NO"},{"text":"PLP and WCP","value":"BO','PL','WC"},{"text":"PLP","value":"BO','PL"},{"text":"WCP","value":"BO','WC"},{"text":"HBP","value":"NO"}], type: 'memory'}}},{id:"paramid_40",height:200,width:400,xtype:"multiselect",fieldLabel:"Role",indicatorText:"*",indicatorCls:"red-text",store:{model:Ext.define("model__paramid_40", {extend: "Ext.data.Model", fields:[{name:"text",type:"string"},{name:"value",type:"string"}],idProperty:"value" }),storeId:"store__paramid_40",autoLoad:true,proxy:{data:[{"text":"Board President","value":"Board President"},{"text":"Finance Officer","value":"Finance Officer"},{"text":"General Manager","value":"General Manager"},{"text":"Primary Contact","value":"Primary Contact"},{"text":"Safety Officer","value":"Safety Officer"}], type: 'memory'}},selectedItems:[{text:"Board President",value:"Board President"}],valueField:"value",allowBlank:false,blankText:"Role is required",multiSelect:true}],layout:"form",collapsible:true,title:"Parameters"},{id:"cbOutputType",width:320,xtype:"combobox",fieldLabel:"Output Type",formItemCls:"createReportOutputType",invalidCls:"error",labelClsExtra:"createReportParamLabel",msgTarget:"under",indicatorText:"*",indicatorCls:"red-text",allowBlank:false,blankText:"Output type is required",emptyText:"Select a value",editable:false,selectedItems:[{value:"Excel"}],queryMode:"local",store:[["Excel","Excel"]]}],bodyPadding:5,buttonAlign:"left",buttons:[{id:"extBtnCreate",iconCls:"#ReportGo",text:"Run Report",directEvents:{click:{fn:function(item,e){Ext.net. directRequest({isUpload:true,before:function(el,ty pe,action,extraParams,o){if(!App.extFrmPnlParamsDe tails.getForm().isValid()) { return false; }},userSuccess:function(response,result,el,type,ac tion,extraParams,o){download('13', 'http://localhost:61999/PluginRSF/Report/ProcessReport');},userFailure:function(response,re sult,el,type,action,extraParams,o){Ext.Msg.show({t itle : 'Error',
msg : 'Run Report has failed.',
icon : Ext.Msg.ERROR,
buttons : Ext.Msg.OK
});},control:this});}}}},{id:"extBtnCancel",hidden:true,iconCls:"#Cancel",text:"Cancel",listeners:{beforerender:{fn:function(item){if(par ent.reportDefinition){ this.hidden=false; }}},click:{fn:function(item,e){parent.reportDefini tion.hide();}}}}],url:unescape("%2fApp_Legacy%2fSDRMA.Web.PluginRSF.dll%2fSDRMA.We b.PluginRSF.Areas.Views.Report.CreateReport.aspx%3 f_dc%3d1422293213328%26ReportName%3dMember%252BInf o%252BMerge%26memberid%3d9567130d-3921-4628-990a-2221e8e52d0d"),waitMsgTarget:"",fieldDefaults:{labelAlign:"top",msgTarget:"side"}}],layout:"fit"});App.paramid_41.setSelectedItems([{"text":"All","value":"BO','PL','WC','NO"}]);App.paramid_40.setSelectedItems([{"text":"Board President","value":"Board President"}]);App.paramid_40.fireEvent("click");});
//]]>
</script>


EDIT: I have just tried msParam.SetValue(value); and that is working. Can you clarify why the msParam.SelectedItems.Add works for combobox and not multiselect. Thanks

fabricio.murta
Jan 26, 2015, 6:55 PM
multiselect is kind of specialized multicombobox. I think the multicombobox works fine with the .AddSelectedItem() approach but, again, its a multicombobox. :)

For example, multiselects can have their items reordered by dragging if you enable so. I don't believe multiComboBoxes supports that.

This might be helpful: MultiSelect & ItemSelector (http://dev.sencha.com/extjs/5.0.0/examples/multiselect/multiselect-demo.html)

Maybe you are also interested in this old post for a working version (although from Ext.NET 1.x): [CLOSED] Set MultiSelect selected items during DirectEvent (http://forums.ext.net/showthread.php?10090-CLOSED-Set-MultiSelect-selected-items-during-DirectEvent)

I hope this helps clarify it.

LAEUser
Jan 28, 2015, 11:17 AM
Great. thank you for the information. Please close.
thanks