Author Topic: Changes not seen when user clicks outside grid  (Read 4820 times)

bmais

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 12
    • View Profile
Changes not seen when user clicks outside grid
« on: November 05, 2013, 06:28:11 am »
Is there a way to fire the saveEditCell when the grid looses focus?  My users will edit a cell and then click elsewhere on the form.  The cellUnSelect event is ignored.

Thanks

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Changes not seen when user clicks outside grid
« Reply #1 on: November 05, 2013, 07:03:40 pm »
Bill

You can use on jQuery API http://api.jquery.com/on/ to add delegate blur event something like this

$( document ).on ( "blur", ".pq-editor-focus", function(evt){
  var $grid = $(this).closest(".pq-grid");
  $grid.pqGrid("saveEditCell");
});

you may need to make minor adjustments to this code.

bmais

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Changes not seen when user clicks outside grid
« Reply #2 on: February 20, 2014, 11:50:51 pm »
We just noticed this code messes with the grid calendar. 
The calendar displays but you cannot choose a date. 
The error message is:
Uncaught Missing instance data for this datepicker

We modified your code as follows:
$( document ).on ( "blur", ".pq-editor-focus", function(evt){
  var $grid = $(this).closest(".pq-grid");
  //$grid.pqGrid("saveEditCell");
  $grid.pqGrid("quitEditMode");
});

Any thoughts?
Thanks,
Bill

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Changes not seen when user clicks outside grid
« Reply #3 on: February 22, 2014, 12:36:49 am »
Any editor which requires the focus outside of the textbox to function would be problematic e.g. datepicker, autocomplete.

datepicker can be excluded from this rule:

$(document).on("blur", ".pq-editor-focus:not(.hasDatepicker)", function (evt) {
      var $grid = $(this).closest(".pq-grid");
      //$grid.pqGrid("saveEditCell");
      $grid.pqGrid("quitEditMode");
});
« Last Edit: February 22, 2014, 12:46:06 am by paramquery »