views:

3113

answers:

1

I am using a JQGrid in one of my ASP.NET projects where the grid shows a list of items that are sortable/filterable (That's all working fine)

The only problem im having with it is, one of the columns is a date field so I have the filter textbox using the date picker (using the below options)

{ name:'Due',
  index:'Due', 
  width:100, 
  align:"center",
  searchoptions:{
      dataInit:function(el){
          $(el).datepicker({dateFormat:'dd-mm-yy'});
      }
   }
 }

But when I select a date from the date picker it's not refreshing the grid automatically (like the dropdowns do) I have to click the textbox again and press enter.

Is there a way to fix this?

jqGrid 3.5 beta

+3  A: 

I haven't used JQGrid, but from the documentation you should be able to do something like this:

{
    name:'Due',
    index:'Due', 
    width:100, 
    align:"center",
    searchoptions:{
     dataInit:function(el){
      $(el).datepicker({
       dateFormat:'dd-mm-yy',
       onSelect: function(dateText, inst){ $("#grid_id")[0].triggerToolbar(); }
      });
     }
    }
}

Don't forget to change the #grid_id to the selector that matches your grid.

Updated: Changed $("#grid_id").trigger("reloadGrid"); to $("#grid_id")[0].triggerToolbar();. Tested this on the jqGrid 3.5b demos and it works.

Jason Berry
Hey Jason, that kinda works, it triggers the reloading of the grid, but not with the new data... any other ideas?
d1k_is
I've updated the solution. It worked on the demo I tested it on!
Jason Berry
Perfect! Thanks for your help, but how did you find that?
d1k_is
I looked through the source code of jqGrid until I found what I was looking for - it wasn't documented anywhere that I could see! I would imagine that this is a temporary workaround until the developers add this to be the default jqGrid functionality - you might like to suggest it to them?
Jason Berry