EasyUI Forum
June 30, 2024, 09:10:17 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Disable combobox editor in a datagrid programatically  (Read 7862 times)
thecyberzone
Full Member
***
Posts: 176



View Profile Email
« on: June 26, 2019, 02:08:06 AM »

In a editable datagrid a combobox editor column (CALDATE) is populated from a php url (code is given below). Now I cannot disable this combox editor when no record returned from the php call. Please help me.

Code:
		onBeforeEdit: function(index,row){
row.editing = true;
$(this).datagrid('updateRow',{index:index, row:{}});

  var colDate = $(this).datagrid('getColumnOption', 'CALDATE');
  colDate.editor = {
    type:'combobox',
    options:{
    method: 'get',
    valueField:'ST_DT',
textField:'ST_DT',
panelHeight:100,
url: 'getDate.php?dt1='+cald1+'&dt2='+cald2+'&pc='+row.PROGCODE
}
};
//if (colDate.editor.combobox('getData').length==0){
// colDate.editor = null;
//}
$(this).datagrid('fixRowHeight');
}
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: June 27, 2019, 07:21:15 AM »

With the 'onBeginEdit' event, you can get the combobox editor and disable it.
Code:
onBeginEdit: function(index,row){
var ed = $(this).datagrid('getEditor', {index:index,field:'CALDATE'});
var combo = $(ed.target);
combo.combobox('disable')
}
Logged
thecyberzone
Full Member
***
Posts: 176



View Profile Email
« Reply #2 on: June 27, 2019, 08:19:26 AM »

But how I will determine that php url return zero number of rows? That is how to determine the length of data populeted in combobox. Actually I want to disable combobox when there is no rows in combobox dropdown.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: June 27, 2019, 11:32:14 PM »

You can listen to the 'onLoadSuccess' event. If no data returned then disable it.
Code:
{
type:'combobox',
options:{
method: 'get',
valueField:'ST_DT',
textField:'ST_DT',
panelHeight:100,
url: 'getDate.php?dt1='+cald1+'&dt2='+cald2+'&pc='+row.PROGCODE,
onLoadSuccess: function(data){
if (!data.length){
// disable it
}
}
}
}
Logged
thecyberzone
Full Member
***
Posts: 176



View Profile Email
« Reply #4 on: June 28, 2019, 01:20:59 AM »

What I have done is given below, but still now combobox is functioning, typing can be done in this combobox, 'Disabled' not done.

Code:
 			var colDate = $(this).datagrid('getColumnOption', 'CALDATE');
  colDate.editor = {
    type:'combobox',
    options:{
    method: 'get',
    valueField:'ST_DT',
textField:'ST_DT',
panelHeight:100,
url: 'getDate.php?dt1='+cald1+'&dt2='+cald2+'&pc='+row.PROGCODE,
onLoadSuccess: function(data){
if (!data.length){
var ed = $(this).datagrid('getEditor', {index:index,field:'CALDATE'});
var combo = $(ed.target);
combo.combobox('disable');
}
}
}
};

Although in combobox there is no row displayed.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #5 on: June 29, 2019, 12:56:51 AM »

The code should be:
Code:
onLoadSuccess: function(data){
if (!data.length){
$(this).combobox('disable');
}
}
Logged
thecyberzone
Full Member
***
Posts: 176



View Profile Email
« Reply #6 on: June 29, 2019, 07:57:50 AM »

Thanks, working successfully.
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!