EasyUI Forum
May 15, 2024, 11:53:01 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: DataGrid Filter Row - Use remote datebox filter with the Date as long value?  (Read 10097 times)
Stefan B.
Full Member
***
Posts: 152


Software Architekt


View Profile Email
« on: July 01, 2014, 04:22:51 AM »

We will use the DataGrid Filter Row with an datebox filter.
Code:
field:'changeDate',
type:'datebox',
op:['equal','notequal','less','lessorequal','greater','greaterorequal'],
options:{
  panelWidth: '240',
  editable: true
}

But the filter extension only send the date as value string to the remote server (FilterRules) like this
Code:
<jsonFilterRules: [{"field":"changeDate","op":"equal","value":"01.06.2014"}]>

But the DAO on server side use a Date field as a long value (not a String value).

How can we use the datebox filter to send the "long date value" from the date object of the datebox to the remote filter rules?
Logged
jarry
Administrator
Hero Member
*****
Posts: 2264


View Profile Email
« Reply #1 on: July 02, 2014, 12:11:42 AM »

You can override the 'filterStringify' function to define how to stringify the 'filterRules' parameter value before sending the filter request to server.
Code:
$('#dg').datagrid({
filterStringify: function(data){
$.map(data, function(item){
if (item.field == 'changeDate'){
item.value = Date.parse(item.value);
}
});
return JSON.stringify(data);
}
})
Logged
Stefan B.
Full Member
***
Posts: 152


Software Architekt


View Profile Email
« Reply #2 on: July 02, 2014, 05:04:14 AM »

Sorry but the datebox used an user defined formatter and parser to show the date in datagrid, formated in german style.
In oure example that is the geman formated date "02.07.2014"

But then the filter use the value extend from combo component. And this is in language specific format.
But the javascript function Date.parse(value) can only use the dateString as a string representing an RFC2822 or ISO 8601 date format.

I mean there should be a way to configure the filter of type datebox to return the value string or the intenal calender date object!
Then it is flexible.
Logged
jarry
Administrator
Hero Member
*****
Posts: 2264


View Profile Email
« Reply #3 on: July 02, 2014, 08:11:30 AM »

Please use $.fn.datebox.defaults.parser function to parse a Date object instead.
Code:
$('#dg').datagrid({
filterStringify: function(data){
$.map(data, function(item){
if (item.field == 'changeDate'){
item.value = $.fn.datebox.defaults.parser(item.value).getTime();
}
});
return JSON.stringify(data);
}
})
Another solution to solve your issue is to convert these values in your server side.
Logged
Stefan B.
Full Member
***
Posts: 152


Software Architekt


View Profile Email
« Reply #4 on: July 02, 2014, 11:49:13 PM »

Thank you for your support. This works very well.
I also test the way to convert the date on server side.
Both works.
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!