tabalinas / jsgrid

Lightweight Grid jQuery Plugin
http://js-grid.com
MIT License
1.53k stars 353 forks source link

Add or editing row in an other URL #1395

Open adrianogoncalves opened 3 years ago

adrianogoncalves commented 3 years ago

Hi, I would like to know if it is possible to redirect the user to another page when clicking on add or edit buttons. I would like to do it externally and, after that, return to the grid.

Congratulations by your great job on jsGrid, and thanks in advance!

Adriano Gonçalves

herickbrandao commented 3 years ago

You can customize your jsGrid like:

$("#grid").jsGrid({
   ...

   /* Insert button */
   onItemInserting: function(args) {
      // cancel insertion of the item and do anything you want
      args.cancel = true;

      // redirect
      window.location = "http://your-url.example/insert?ID=" + args.item.ID;
   },

   /* Edit button */
   onItemEditing: function(args) {
      // cancel edition of the item and do anything you want
      args.cancel = true;

      // redirect
      window.location = "http://your-url.example/edit?ID=" + args.item.ID;
   }
);

More: http://js-grid.com/docs/#callbacks