EasyUI Forum
May 17, 2024, 06:42:44 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: push to data array onLoadSuccess [solved]  (Read 9519 times)
devnull
Sr. Member
****
Posts: 431


View Profile
« on: March 01, 2013, 04:00:49 AM »

I am trying to push a row to the combobox after it has loaded it's data when the element's "all" attribute is set.

The data gets appended, however I am unable to push this data back to the combobox as it results in recursion with onLoadSuccess.

How can I achieve this ??

Code:
<label>Employee</label><input type="text" name="userid" class="easyui-combobox fkey" url="/intra/php/dget.php?_id_=userid" all="y"></input>

Code:
$.extend($.fn.combobox.defaults, { valueField: 'val',textField: onLoadSuccess:cbOnLoad});

function cbOnLoad(data){
if($(this).attr('all')){
data.push({txt:'All',val:'*',selected:true});
$(this).combobox('loadData',data);
}
}


« Last Edit: March 01, 2013, 05:35:42 AM by devnull » Logged

-- Licensed User --
devnull
Sr. Member
****
Posts: 431


View Profile
« Reply #1 on: March 01, 2013, 05:35:01 AM »

solved by pushing to first element and then checking if Exists:

Code:
function cbOnLoad(data){
if($(this).attr('all')){
if(data[0].txt != 'All') {
data.unshift({txt:'All',val:'*',selected:true});
$(this).combobox('loadData',data);
}

}
}

Is there a better / more efficient method ??
« Last Edit: March 01, 2013, 06:10:54 AM by devnull » Logged

-- Licensed User --
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!