jQWidgets Forums
jQuery UI Widgets › Forums › Grid › attempt to remove a row jqxgrid
This topic contains 8 replies, has 2 voices, and was last updated by Hristo 8 years, 9 months ago.
-
Author
-
Here is how I am trying to get rid of the specific row from the jqxGrid. I read on the forums that in order to delete a specific row, I just need to use the deleterow method and not the deleterow function. I tried using the function as follows in the following jqxGrid but it didn’t work. Please note that I don’t need any click handler
to get the rowid. I already know that I want to delete row with name “B”. Please let me know what I am doing wrong?If I have to define deleterow method in the newSource, then won’t it be like defining a function over there which is not recommended if I am not dealing with server side stuff,confusing to me?
Hello walker1234,
The deleterow callback is used common case in server side logic.
When you implement ‘deleterow’ need to add and commit(true/false) thus as in your example when you try to use method deleterow will not work.Please, take a look at this example:
https://jsfiddle.net/txhi/7ucvy5yr/Best Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.comHi Hristo,Thanks. Why is it deleting row with name “D” as well along with “B” in your JSFiddle ?
Also, why do you have the following defined in the end?
$('#jqxgrid').jqxGrid('deleterow', 1); $('#jqxgrid').jqxGrid('deleterow', 2); $('#jqxgrid').jqxGrid('deleterow', 3);
Thanks
In addition to above question, I was wondering if there is a way to use the actual value of the column instead of row id ?
Hello walker1234,
Yes it is possible – if you add in the source ‘id’ property with desire dataField
(ex:var newSource = { localdata: array, datafields: [..], id: 'name' }
then you can use$('#jqxgrid').jqxGrid('deleterow', 'A');
– delete by name).
More correctly and safety will be to use as described in the documentation – to get row id (with ‘getboundrows’) and then to use “deleterow”.Best Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.comThanks Hristo. I tried doing what you suggested and added the id as follows in the following JSFiddle but it didn’t work. Am I missing anything?
var newSource = { localdata: array, datafields: [{ name: 'name', type: 'string', map: 'key', id: 'name' },
And secondly, if I have to use the
getboundrows
as per the documentation below, then in the case when we don’t know which row we need to delete, I mean the row name can be anywhere in the list so it won’t be possible to use something likerows[0]
for push, right?var rows = $(“#jqxgrid”).jqxGrid(‘getboundrows’);
// populate an array with the first and second row ids. “uid” is the row’s id.
var rowIDs = new Array();
rowIDs.push(rows[0].uid);
rowIDs.push(rows[1].uid);
// delete the first and second rows.
$(“#jqxgrid”).jqxGrid(‘deleterow’, rowIDs);Hello walker1234,
This is not correct place for
id
-> need to be on same level asdataFields
.
Please, take a look this example.Best Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.comThanks Histro for example. One last question, why have you used
cl(rowid)
inside deleterow method? What does it indicates? ThanksHello walker1234,
This is redundant row.
Best Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.