Jan 26, 2015, 4:34 PM
[CLOSED] SelectedItem for MultiSelect Ext 2.5.2 Webforms
I am having trouble setting a selected item for a multiselect. This is from code behind.
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
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",aspF orm:"theForm",theme:"gray",icons:[{name:"ReportGo",url:"/WebResource.axd?d=1IH1P8W6qJrIcCjztWRe0zWV487m5f-dqaY2ADT-oPuArB1dL3KX1uRJp-CMxjqR3dMu3lixqQeQ_MXCwXJ6o5ZMSQ3PnJcA1syOj_WcZyRK GQOfc_wiA-78x22WZoDB1GEjYQ2&t=635476769949990000"},{name :"Cancel",url:"/WebResource.axd?d=pMMYDmRNkggusLes_mX6xgQ55wYu4SO-hFxNRhXlcOSLV_i-EvMEMZj_X8lhCI-e22-wAlABFX-OeZGSFxdzKyw6nDK0gxL_z8Mz5s1FgtXBS7Tw0&t=63547 6769949990000"}]});Ext.onReady(function(){Ext.create("Ext.panel.Pa nel",{id:"extPnlCreateReportParams",border:false,r enderTo:"App.extPnlCreateReportParams_Container",i tems:[{id:"extFrmPnlParamsDetails",border:false,xtype:"f orm",items:[{id:"extFldSetParams",padding:"10 10 20 10",xtype:"fieldset",defaults:{"msgTarget":"under" ,"labelWidth":115,"labelCls":"createReportParamLab el"},items:[{id:"paramid_41",width:400,xtype:"combobox",fieldL abel:"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:"st ring"}],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"},{"tex t":"HBP","value":"NO"}], type: 'memory'}}},{id:"paramid_40",height:200,width:400, xtype:"multiselect",fieldLabel:"Role",indicatorTex t:"*",indicatorCls:"red-text",store:{model:Ext.define("model__paramid_40", {extend: "Ext.data.Model", fields:[{name:"text",type:"string"},{name:"value",type:"st ring"}],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:"Ro le is required",multiSelect:true}],layout:"form",collapsible:true,title:"Parameters" },{id:"cbOutputType",width:320,xtype:"combobox",fi eldLabel:"Output Type",formItemCls:"createReportOutputType",invalid Cls:"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){E xt.net.directRequest({isUpload:true,before:functio n(el,type,action,extraParams,o){if(!App.extFrmPnlP aramsDetails.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:{b eforerender:{fn:function(item){if(parent.reportDef inition){ this.hidden=false; }}},click:{fn:function(item,e){parent.reportDefini tion.hide();}}}}],url:unescape("%2fApp_Legacy%2fSDRMA.Web.PluginRSF .dll%2fSDRMA.Web.PluginRSF.Areas.Views.Report.Crea teReport.aspx%3f_dc%3d1422293213328%26ReportName%3 dMember%252BInfo%252BMerge%26memberid%3d9567130d-3921-4628-990a-2221e8e52d0d"),waitMsgTarget:"",fieldDefaults:{lab elAlign:"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>
//<![CDATA[
Ext.net.ResourceMgr.init({id:"ScriptManager1",aspF orm:"theForm",theme:"gray",icons:[{name:"ReportGo",url:"/WebResource.axd?d=1IH1P8W6qJrIcCjztWRe0zWV487m5f-dqaY2ADT-oPuArB1dL3KX1uRJp-CMxjqR3dMu3lixqQeQ_MXCwXJ6o5ZMSQ3PnJcA1syOj_WcZyRK GQOfc_wiA-78x22WZoDB1GEjYQ2&t=635476769949990000"},{name :"Cancel",url:"/WebResource.axd?d=pMMYDmRNkggusLes_mX6xgQ55wYu4SO-hFxNRhXlcOSLV_i-EvMEMZj_X8lhCI-e22-wAlABFX-OeZGSFxdzKyw6nDK0gxL_z8Mz5s1FgtXBS7Tw0&t=63547 6769949990000"}]});Ext.onReady(function(){Ext.create("Ext.panel.Pa nel",{id:"extPnlCreateReportParams",border:false,r enderTo:"App.extPnlCreateReportParams_Container",i tems:[{id:"extFrmPnlParamsDetails",border:false,xtype:"f orm",items:[{id:"extFldSetParams",padding:"10 10 20 10",xtype:"fieldset",defaults:{"msgTarget":"under" ,"labelWidth":115,"labelCls":"createReportParamLab el"},items:[{id:"paramid_41",width:400,xtype:"combobox",fieldL abel:"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:"st ring"}],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"},{"tex t":"HBP","value":"NO"}], type: 'memory'}}},{id:"paramid_40",height:200,width:400, xtype:"multiselect",fieldLabel:"Role",indicatorTex t:"*",indicatorCls:"red-text",store:{model:Ext.define("model__paramid_40", {extend: "Ext.data.Model", fields:[{name:"text",type:"string"},{name:"value",type:"st ring"}],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:"Ro le is required",multiSelect:true}],layout:"form",collapsible:true,title:"Parameters" },{id:"cbOutputType",width:320,xtype:"combobox",fi eldLabel:"Output Type",formItemCls:"createReportOutputType",invalid Cls:"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){E xt.net.directRequest({isUpload:true,before:functio n(el,type,action,extraParams,o){if(!App.extFrmPnlP aramsDetails.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:{b eforerender:{fn:function(item){if(parent.reportDef inition){ this.hidden=false; }}},click:{fn:function(item,e){parent.reportDefini tion.hide();}}}}],url:unescape("%2fApp_Legacy%2fSDRMA.Web.PluginRSF .dll%2fSDRMA.Web.PluginRSF.Areas.Views.Report.Crea teReport.aspx%3f_dc%3d1422293213328%26ReportName%3 dMember%252BInfo%252BMerge%26memberid%3d9567130d-3921-4628-990a-2221e8e52d0d"),waitMsgTarget:"",fieldDefaults:{lab elAlign:"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>
Last edited by fabricio.murta; Jan 28, 2015 at 4:46 PM.
Reason: [CLOSED]