jQuery UI Widgets Forums Grid selected row index

This topic contains 2 replies, has 2 voices, and was last updated by  Stanislav 7 years, 2 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • selected row index #94896

    Manowar
    Participant
            $("#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

    selected row index #94901

    Stanislav
    Participant

    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 its index.

    Best Regards,
    Stanislav

    jQWidgets Team
    http://www.jqwidgets.com/

    selected row index #94906

    Stanislav
    Participant

    Hi Manowar,

    You can also go through this Thread. It is similar to your question and might find it helpful, although it’s pretty old.

    Best Regards,
    Stanislav

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.