EasyUI Forum
April 29, 2024, 01:57:56 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: easyui-searchbox used like lookup widget issue  (Read 7359 times)
r2ferna
Newbie
*
Posts: 21


View Profile
« 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.

Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 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]);
});
}
});
Logged
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!