EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: r2ferna on September 17, 2013, 08:08:50 AM



Title: easyui-searchbox used like lookup widget issue
Post by: r2ferna on September 17, 2013, 08:08:50 AM
Hi!
I'm using the searchbox as a lookup widget. I mean, when click the magnifier icon of the searchbox it fires other Window with a datagrid showing records of x-table where I can select one of them.
I chossen the searchbox because the magnifier is "atached" to the widget and no need for other button to show the magnifier.
All is ok when I create a Record! The issues come when I use the form for update records. The searchbox "takes" the row value as the prompt and so it disapears when I click the searchbox.

This is the JS function for Record Updates .

function editaRegistro(){
      row = $('#dg').datagrid('getSelected'); 
      if (row){                       
          $('#dlg').dialog('open').dialog('setTitle','Modificando: ' + row.user_id);
          $('#fm').form('clear');           
          $('#fm').form('load',row);
          $('#inpTipoUsuario').searchbox('setValue', row.usertype);
          url = "w-usuarios?fnId=modificaUsuario";
      } else {$.messager.alert('Aviso', 'Por favor, primero, seleccione el registro que desea modificar.', 'info');} 
    } 

As you can see, I have to set the searchbox value, so the value don't dissapear when I click the searchbox:
 $('#inpTipoUsuario').searchbox('setValue', row.usertype);

This workaround does the work, but I have 10 searchboxes and I don't like to set the values one by one.
Is there a way so searchboxes can "take" the datagrid row value as the input value not as the prompt? Like validatebox it does!

MTIA.



Title: Re: easyui-searchbox used like lookup widget issue
Post by: stworthy on September 17, 2013, 06:40:07 PM
Please try the code below:
Code:
$.extend($.fn.form.defaults, {
onLoadSuccess:function(data){
$(this).find('input.searchbox-text').each(function(){
var name = $(this).attr('name');
var t = $(this).parent().prev();
t.searchbox('setValue', data[name]);
});
}
});