5

How exactly are you meant to use the methods for jQuery BootGrid?

I've tried:

$("#presentation-listing-api").bootgrid('remove', [uid]);

Doesn't seem to be working?

It's not helpful that the documentation isn't quite finished yet.

Rafael Staib
  • 1,226
  • 12
  • 14
RTolton
  • 53
  • 1
  • 4
  • 2
    Show us your full code and html. – Rohan Kumar Sep 02 '14 at 10:14
  • Well their [online demos](http://www.jquery-bootgrid.com/Examples#1) seem to work. You could copy one of them as a starting point?# – Rup Sep 02 '14 at 10:15
  • 1
    The online examples they have don't actually show the use of methods like 'remove' etc. I guess this is really a question for the author. There's not much code to share other than the fact that #presentation-listing-api is an HTML table. – RTolton Sep 03 '14 at 12:14

3 Answers3

10

It should be noted, as of version [1.3.1], the "remove" feature is not supported when using the ajax option. There is a note in the source that reads

[ todo: implement ajax DELETE]

An alternative could be something like this:

$('[data-row-id="'+uid+'"]').remove();
JimDeavers
  • 101
  • 1
  • 5
  • Note that this removes the representation of the row, but if you change page (from the pagination buttons) and come back, the row reappears – Rombus Mar 14 '17 at 19:50
  • 1
    @Rombus If not using the **ajax** option, that is correct. However, I assumed anyone using the ajax method (and associated JSON objects) would _also_ be handling removal of the row from the results. All of this is probably meaningless, since I doubt the original question was related to server-side / **ajax** data anyway. Thanks for your comment! – JimDeavers Mar 15 '17 at 22:32
5

The way to do it was kind of convoluted but I figured it out...

You have to mark your id column as an identifier and the type to numeric like this:

<th data-column-id="id" data-identifier="true" data-type="numeric">ID</th>

Then, MAKE SURE the values in that column are unique!!!

Then call the remove like this:

rows[0] = uid;
$("#presentation-listing-api").bootgrid('remove', rows);

What I did was took the Commands demo and modified it to load just some data then worked on getting the remove to work.

Here's a working fiddle:
http://jsfiddle.net/Mrbaseball34/zszc8zL6/

jameshwart lopez
  • 2,993
  • 6
  • 35
  • 65
MB34
  • 4,210
  • 12
  • 59
  • 110
  • Also very important to note that data-type="numeric" is necessary or else it won't work. – VVV Jan 06 '16 at 19:06
1

Make sure you have the "id" variable as an integer in the associated object you are using to fill the table. With parseInt() worked even with ajax: false.