EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: kush on February 02, 2015, 04:33:30 AM



Title: Combobox is not giving valueField value to post the parameters!!!!Urgent help re
Post by: kush on February 02, 2015, 04:33:30 AM
Hi ,
     Combobox type editor is not giving me value while posting the form data.How to pic the id from the Combobox List.As its only giving me the text value from datagrid row
for eg :- In my html i have below cfr-cu textbox of type combo.
In HTML:-
<input id="cfr_cu" class="easyui-combobox" name="cfr_name" data-options="valueField:'id',textField:'text'">
And I am loading dynamic data in my javascript like below
var ch =[{"id":"1","text":"AT&T"},{"id":"5","text":"BAMA"},{"id":"2","text":"ECSO"}]
$('#cfr_cu').combobox('loadData', ch);
$('#cfr_cu').combobox('setValue', editedPrjJson.cfr_name);//The Selected Value which I am getting it from Editors of Datagrid.
var editors = $('#dg').edatagrid('getEditors', editRowIndex);
   for (var i = 0; i < editors.length; i++) {
       //console.log(editors.target);
      obj += '"'+editors.field+'":"'+editors.oldHtml+'"';
      if(i<editors.length-1){
        obj +=',';
      }
      
   }

But I am not getting the valueField:'id' ...Please help me ASAP....


Thank you,
Kush


Title: Re: Combobox is not giving valueField value to post the parameters!!!!Urgent help re
Post by: kush on February 02, 2015, 04:39:15 AM
Only on change of combobox its setting the valueField..please help me urgent


Title: Re: Combobox is not giving valueField value to post the parameters!!!!Urgent help re
Post by: stworthy on February 02, 2015, 06:56:13 PM
$('#cfr_cu').combobox('setValue', editedPrjJson.cfr_name);//The Selected Value which I am getting it from Editors of Datagrid.

When calling 'setValue' method to set the combobox's value, you must pass the 'id' to this method. The 'id' field name has been defined in 'valueField' property. If your 'editedPrjJson.cfr_name' value only stores the 'text', please use the 'value' instead.
Code:
$('#cfr_cu').combobox('setValue', '1');
$('#cfr_cu').combobox('setValue', '2');
$('#cfr_cu').combobox('setValue', '5');


Title: Re: Combobox is not giving valueField value to post the parameters!!!!Urgent help re
Post by: kush on February 02, 2015, 11:00:45 PM
Yes I understand that I should set the Value.But I can't set static values.On click of Row edit in Datagrid I m getting the Values and populating in Popup to edit the datagrid row fields.
And I have put the type of cfr_name as type of combobox
<th data-options="field:'cfr_name',width:'6%',sortalbe:true,align:'center',v
                           editor:{
                                    type:'combobox',
                                    options:{
                                    valueField:'id',
                                    textField:'text',
                                    method:'get',
                                    url:'/demand/?action=get_cfr_list',
                                    }
                                 }">CFR</th>
But I m retrieving the edited row details on click of row in Datagrid.
If I select the data from drop down Its selecting the value and posting to server 'value',If I dont Select Its sending me the 'text' as 'value'

My datagrid json data ex of 1 row...
[{"project_id":"13","project_name":"xxx", Device Lab_EEDJOME","cfr_name":"Vz KAM - Jon Meier"
Do I need to send  combobx structure data with in the Json data of Datagrid?pls help


Title: Re: Combobox is not giving valueField value to post the parameters!!!!Urgent help re
Post by: stworthy on February 02, 2015, 11:46:17 PM
Your 'cfr_name' field value does not match the combobox's value. Please use another 'cfr_id' field to bind the combobox editor and then define the 'formatter' function to display the 'cfr_name' field value. The code looks like this:
Code:
<th data-options="field:'cfr_id',width:'6%',sortalbe:true,align:'center',
formatter:function(value,row){
return row.cfr_name;
},
       editor:{
                type:'combobox',
                options:{
                valueField:'id',
                textField:'text',
                method:'get',
                url:'/demand/?action=get_cfr_list',
                }
             }">CFR</th>

Also, you need to update the 'cfr_name' field value after the editing action is finished.
Code:
$('#dg').datagrid({
onEndEdit: function(index,row){
var ed = $(this).datagrid('getEditor',{index:index,field:'cfr_id'});
row.cfr_name = $(ed.target).combobox('getText');
}
})


Title: Re: Combobox is not giving valueField value to post the parameters!!!!Urgent help re
Post by: kush on February 03, 2015, 05:23:28 AM
Thank u for the valuable responce. It worked..