EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: correohs on February 06, 2013, 02:33:08 PM



Title: dosearch + combobox ( How to make it to work ? )
Post by: correohs on February 06, 2013, 02:33:08 PM
How to does combobox works with dosearch?

lo_month_sel means  layout month selected
lo_empl_id_sel means layout employee ID selected

Thanks!

function doSearch(){
         $('#dg').datagrid('load',{
            lo_month_sel: $('#lo_month_sel').val(),
            lo_empl_id_sel: $('#lo_empl_id_sel').val()
         });
      }



<? /* --------     this part works great! -------------------------- */        
$curr_month = date("m");
$lo_month_sel = array (0=>"All", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
$select = "<select id=\"lo_month_sel\">\n";
foreach ($lo_month_sel as $key => $val) {
    $select .= "\t<option value=\"".$key."\"";
    if ($key == $curr_month) {
        $select .= " selected=\"selected\">".$val."</option>\n";
    } else {
        $select .= ">".$val."</option>\n";
    }
}
$select .= "</select>";
echo $select;

?>

/* ----------------------------------------------------- This Part Do Not works well for me --------- */
<span>Empl ID:</span>
<?   input id="lo_empl_id_sel" class="easyui-combobox"
        name="lo_empl_id_sel"
      data-options="
               url:'get_empl_dropdown.php',
               valueField:'emp_code',
               textField:'emp_last_name',
               panelHeight:'auto',
                    required:true
         ">
        
        
      <a href="#" class="easyui-linkbutton" plain="true" onClick="doSearch()">Search</a>


Title: Re: dosearch + combobox ( How to make it to work ? )
Post by: stworthy on February 06, 2013, 06:20:42 PM
To get a combobox value, please use 'getValue' method.

Code:
function doSearch(){
$('#dg').datagrid('load',{
lo_month_sel: $('#lo_month_sel').combobox('getValue'),
lo_empl_id_sel: $('#lo_empl_id_sel').combobox('getValue')
});
}


Title: Re: dosearch + combobox ( How to make it to work ? )
Post by: correohs on February 06, 2013, 10:50:24 PM
stworthy  thank you so much for your reply but it didn't work when I tested it.

This is the Function I had, it works well using input
------------------------------------------------
function doSearch(){
         $('#dg').datagrid('load',{
               lo_empl_id_sel: $('#lo_empl_id_sel').val()
         });
      }

<input id="lo_empl_id_sel" style="line-height:26px;border:1px solid #ccc">  

<a href="#" class="easyui-linkbutton" plain="true" onClick="doSearch()">Search</a>  


-----------------------------------------------------------------------------------------
It work GREAT! Thanks Stworthy
-----------------------------------------------------------------------------------------
function doSearch(){
   $('#dg').datagrid('load',{
      lo_empl_id_sel: $('#lo_empl_id_sel').combobox('getValue')
   });
}


<span>Empl ID:</span>
<?   input id="lo_empl_id_sel" class="easyui-combobox"
        name="lo_empl_id_sel"
      data-options="
               url:'get_empl_dropdown.php',
               valueField:'emp_code',
               textField:'emp_last_name',
               panelHeight:'auto',
               required:true
         ">
      
      
<a href="#" class="easyui-linkbutton" plain="true" onClick="doSearch()">Search</a>


Title: Re: dosearch + combobox ( How to make it to work ? )
Post by: stworthy on February 06, 2013, 11:37:20 PM
Please refer to this example http://jsfiddle.net/dYWVX/. It can get the 'lo_empl_id_sel' value properly.


Title: Re: dosearch + combobox ( How to make it to work ? )
Post by: correohs on February 07, 2013, 08:47:59 AM
it works perfect! Thanks!