Hi Abu,
Have a Master/Detail grid case where the Detail grid has a working daterangepicker.
Problem is as follows –
I have $e[“js_on_select_row”] = “resident_changed”; defined in the Master grid
A row is selected in the Master grid containing a username
The Detail grid gets loaded with the calculated last 30 days of data for the new user
In the Detail grid I then change the daterange to “Year to Date”
This works fine with data loaded for the year to date for that username
If I then select a diff Master grid row (for a diff user) the Detail grid loads with the “Year to Date” daterange for the new user
I have code in the “resident_changed” function to change the postData filters to the default “last 30 days” but
when viewing the network traffic the GET request is still being sent using the old “Year to Date” daterange.
This is the relevant code in the “resident_changed” function to reset the postData filter –
mypostData = jQuery(‘#daily_act’).jqGrid(‘getGridParam’,’postData’);
var today = moment().format(‘YYYY-MM-DD’)
var today_minus_29 = moment().subtract(‘days’, 29).format(‘YYYY-MM-DD’)
mypostData.filters = ‘{“groupOp”:”AND”,”rules”:[{“field”:”date”,”op”:”bt”,”data”:”{“start”:”‘+today_minus_29+'”,”end”:”‘+today+'”}”}]}’;
jQuery(‘#daily_act’).jqGrid(‘setGridParam’, {postData: mypostData});
If I write out the postData to the browser Console it appears to look fine to me –
filters: “{“groupOp”:”AND”,”rules”:[{“field”:”date”,”op”:”bt”,”data”:”{\”start\”:\”2019-04-21\”,\”end\”:\”2019-05-20\“}”}]}“
jqgrid_page: 1
nd: 1558371331594
rows: 40
sidx: “date“
sord: “desc“
_search: true
But the post parameters sent to the server contain a filter for the old “Year to Date” range –
list1:
grid_id: daily_act
rowid: 5
first_name: Dotti
last_name: Smith
filters: {“groupOp”:”AND”,”rules”:[{“field”:”date”,”op”:”bt”,”data”:”{\“start\”:\”2019-01-01\”,\”end\”:\”2019-05-20\“}”}]}
_search: true
nd: 1558371331594
rows: 40
jqgrid_page: 1
sidx: date
sord: desc
I also have code in the resident_changed function to reset the daterangepicker to be the last 30 days.
Not sure what I’m doing wrong with this approach.
Any help is most appreciated.
Thanks,
Steve
SOLVED IT.
I finally realized that resetting the daterangepicker values (postData filters) for a Detail grid by using $e[“js_on_select_row”] in the Master grid would NOT work since when using that grid action the request has already been sent to the server (with the wrong date range) before the js routine is called.
After much head banging, I ended up using the grid action – beforeSelectRow where I can reset the postData filters with the dates I wanted before the request was sent to my server –
$grid[“beforeSelectRow”] = “function(ids) { reset_date_pickers(ids); }”;