Modify jquery easyui combobox fuzzy filtering
Copy codeThe Code is as follows:
Filter: function (q, row ){
Var opts = $ (this). combobox ("options ");
// Return row [opts. textField]. indexOf (q) = 0 ;//
Return row [opts. textField]. indexOf (q)>-1; // change the original position to any match.
}, Formatter: function (row ){
Var opts = $ (this). combobox ("options ");
Return row [opts. textField];
}, Loader: function (_ 7c9, _ 7ca, _ 7cb ){
Var opts = $ (this). combobox ("options ");
If (! Opts. url ){
Return false;
}
Modify the easyui combobox extension to select the first line by default.
By default, the first line of the easyui combobox extension is selected. The crazy show on the Internet has been reposted for countless times, but the code is only for easyui1.2.6 and cannot be used in 1.3.2, I re-wrote an extension method as follows:
Copy codeThe Code is as follows:
$. Extend ($. fn. combobox. methods ,{
SelectedIndex: function (jq, index ){
If (! Index ){
Index = 0;
}
$ (Jq). combobox ({
OnLoadSuccess: function (){
Var opt = $ (jq). combobox ('options ');
Var data = $ (jq). combobox ('getdata ');
For (var I = 0; I <data. length; I ++ ){
If (I = index ){
$ (Jq). combobox ('setvalue', eval ('data [index]. '+ opt. valueField ));
Break;
}
}
}
});
}
});
The call method example is as follows:
Copy codeThe Code is as follows:
<Script type = "text/javascript">
Var currenturl = "om_taking.aspx ";
$ (Function (){
$ ('# Dept'). combobox ({
Url: currenturl + "? Act = loadDept ",
ValueField: 'department _ id ',
TextField: 'department _ name'
}). Combobox ('selectedindex ', 0 );
});
</Script>