jQuery UI Widgets › Forums › Grid › selected row index
Tagged: addrow, deleterow, getrowselectedindex, jqxgrid
This topic contains 2 replies, has 2 voices, and was last updated by Stanislav 7 years, 2 months ago.
-
Authorselected row index Posts
-
$("#addrowbutton").bind("click", function () { var datarow; var index = $("#menuCategoryTimeRecipeGrid").jqxGrid('getselectedrowindex'); // getselectedrowindex method ( 2 ) // для добавления вновь созданной строке в плане меню пункта "Время приема пищи", как у выбранной в момент добавления, если она есть if(index != -1 && index != deletedRowIndex) { datarow = generateMenuCategoryTimeRecipe(e.args.element.id, $('#menuCategoryTimeRecipeGrid').jqxGrid('getrowdata', $("#menuCategoryTimeRecipeGrid").jqxGrid('getselectedrowindex')).EatingTimeID); // !!! e } else { datarow = generateMenuCategoryTimeRecipe(e.args.element.id); } // сразу открываем модальное окно для замены рецепта datarow.isAdding = true; createModalToChangeRecipe(datarow); }); // удаление строки в плане-меню $("#menuCategoryTimeRecipeGrid").bind("cellclick", function (event) { if (event.args.columnindex == columnIndexToDeleteRow) { //подумать, как сделать по-другому $("#menuCategoryTimeRecipeGrid").jqxGrid("setcellvalue", event.args.rowindex, "RecordStatusID", 2); deletedRowIndex = $("#menuCategoryTimeRecipeGrid").jqxGrid('getselectedrowindex'); //clearselection method //getselectedrowindex method ( -1 ) }; });
Hello, problem is that when I delete some row in grid and then clear selection in my second event, getselectedrowindex method returns -1
but I got second event, which adds row, and when I add another row, getselectedrowindex returns index of row, that was deleted before (I didn’t select another row in my grid)How can I solve that? Thank you
Hello Manowar,
If you don’t have anything selected when you ‘click’ the
getselectedrowindex
button, it will aways return-1
. After you add the new row, you need to select it and then get itsindex
.Best Regards,
StanislavjQWidgets Team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.