[CLOSED] SelectedItem for MultiSelect Ext 2.5.2 Webforms

  1. #1

    [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.

     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&amp;t=635476769949990000"},{name :"Cancel",url:"/WebResource.axd?d=pMMYDmRNkggusLes_mX6xgQ55wYu4SO-hFxNRhXlcOSLV_i-EvMEMZj_X8lhCI-e22-wAlABFX-OeZGSFxdzKyw6nDK0gxL_z8Mz5s1FgtXBS7Tw0&amp;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>
    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
    Attached Thumbnails Click image for larger version. 

Name:	error.png 
Views:	5 
Size:	34.3 KB 
ID:	19481  
    Last edited by fabricio.murta; Jan 28, 2015 at 4:46 PM. Reason: [CLOSED]
  2. #2
    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

    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

    I hope this helps clarify it.
  3. #3
    Great. thank you for the information. Please close.
    thanks

Similar Threads

  1. [CLOSED] Ext.Net webforms validation summary
    By Maitreya in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Nov 22, 2013, 1:36 PM
  2. MVC vs WebForms
    By yash.kapoor in forum 2.x Help
    Replies: 2
    Last Post: Nov 02, 2012, 3:34 AM
  3. WebForms And MVC Support
    By dimi88 in forum Open Discussions
    Replies: 1
    Last Post: May 18, 2012, 5:32 PM
  4. Replies: 4
    Last Post: May 09, 2012, 9:24 PM
  5. [CLOSED] Question about MVC and webforms
    By idrissb in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Apr 29, 2011, 5:15 PM

Posting Permissions