EasyUI Forum
April 16, 2024, 07:24:15 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: Initialise datebox  (Read 3429 times)
niketa.patel
Newbie
*
Posts: 4


View Profile Email
« on: July 01, 2018, 11:49:43 PM »

Hi,

I would like to initialize databox in Editable datagrid.

I have a grid with two datebox  - startDate and endDate. When I click on datebox then calendar is initialised with current date.
If I select start date as 15-Jul-2015 [which is not current date] then I need to initialise endDate calendar to July 2015 rather than current date.

Can you please help me with this!

Thanks!
Logged
jarry
Administrator
Hero Member
*****
Posts: 2260


View Profile Email
« Reply #1 on: July 02, 2018, 01:51:23 AM »

When begin to edit a row, call the 'getEditor' method to get these two datebox editor and bind an events on the first one, listen to some conditions and set the value for the second one. Please refer to the code below:
 
Code:
$('#dg').datagrid({
  onBeginEdit: function(index,row){
    var db1 = $(this).datagrid('getEditor', {index:index,field:'datebox1'});
    var db2 = $(this).datagrid('getEditor', {index:index,field:'datebox2'});
    $(db1.target).datebox({
      onChange: function(value){
        $(db2.target).datebox('setValue', ...)
      }
    })
  }
})
Logged
niketa.patel
Newbie
*
Posts: 4


View Profile Email
« Reply #2 on: July 03, 2018, 10:55:57 PM »

Thank you for your response!

I did this way as I dont want to set value to second/end datebox

Code:
$('#dg').datagrid({
  onBeginEdit: function(index,row){
var db1 = $(this).datagrid('getEditor', {index:index,field:'datebox1'});
var db2 = $(this).datagrid('getEditor', {index:index,field:'datebox2'});
$(db2.target).textbox('textbox').bind('focus',function(e){

var db1Date = $.fn.datebox.defaults.parser($(db1.target).datebox('getValue'));
if(undefined != $.trim(db1Date) && $.trim(db1Date) != ''){
$(db2.target).datebox('calendar').calendar('moveTo', new Date(db1Date));
}
});
  }
})

Thanks!
« Last Edit: July 03, 2018, 10:58:49 PM by niketa.patel » 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!