Daterange picker

QuestionsDaterange picker
Danish Zafar asked 11 months ago

I am using daterange picker (on column) with a set-on-load filter (1 month range), and i have multiple drop downs search filters on other columns (like user, transaction type). The grid loads the one month data correctly(as set in the load filter), but whenever any of these column search dropdown is selected, the grid ignores the load filter date range criteria and shows all the data.

a. Kindly advise how can i restrict the column filters to follow the load filter JSON OR
b. How can i force daterange picker to select a date range on load(say a month), so other column filters should query the same date range as pre selected in the date range. As currently the daterange picker dont pre-select any date range, the grid load date range from JSON.


// date_default_timezone_set(‘Asia/Karachi’);
$datetime = new DateTime(‘-1 month’);
$v1 = $datetime->format(‘Y-m-d’);
$datetime = new DateTime(‘today’);
$v2 = $datetime->format(‘Y-m-d’);

$sarr = <<< SEARCH_JSON
{“field”:”tran_date”,”op”:”bt”,”data”:”{\”start\”:\”{$v1}\”,\”end\”:\”{$v2} \”}”}
$grid[“search”] = true;
$grid[“postData”] = array(“filters” => $sarr );


$col = array();
$col[“title”] = “Date”;
$col[“name”] = “tran_date”;
$col[“width”] = “120”;
$col[“align”] = “center”;
$col[“formatter”] = “date”;
$col[“formatoptions”] = array(“srcformat”=>’Y-m-d’,”newformat”=>’d/m/Y’);

// date range filter in toolbar
$col[“stype”] = “daterange”;

// Update options for date range picker:
$col[“searchoptions”][“opts”] = array(“initialText”=>”Select range…”);

$cols[] = $col;


View post on

4 Answers
Abu Ghufran Staff answered 11 months ago

I’m regenerating this issue and will be updating back after some testing.

Abu Ghufran - Dev Team
Grid 4 PHP Framework
Danish Zafar answered 11 months ago

Hope you get a solution soon to lock the JSON searching, meanwhile i tried the following way around under function link_daterange_picker(el,opts) in jqgrid_dist.php

var priorDate = moment().subtract(‘days’, 30).startOf(‘day’).toDate();
jQuery(el).daterangepicker(“setRange”, {start: priorDate, end: moment().startOf(‘day’).toDate()});

Now this is locking the the daterange column with a preset range on load (this 30 days range matches with my JSON postData)and allows user to play with other column selectors without loading the whole data in select_command.

Kindly advise if this approach is OK?


Abu Ghufran Staff answered 11 months ago

I’ve created a demo to solve this case. The solution you mentioned changes the base library and will impact all other grids as well which don’t need such daterange locking.

I’m emailing you a library update and a demo which shows how to solve it.

Abu Ghufran - Dev Team
Grid 4 PHP Framework
Danish Zafar answered 11 months ago

Great ! Thanks for your support 🙂

Your Answer

1 + 1 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.

How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?