jQuery UI Widgets Forums Grid After add row, want to select and scroll to new row

This topic contains 1 reply, has 1 voice, and was last updated by  dlinstedt 10 years, 1 month ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author

  • dlinstedt
    Participant

    Using the default code to add a row. It adds row 201 (out of 200 generated rows).
    I would like to select the row, and force the grid to scroll to the selected row.
    I have set the grid scrollable : true

    var row = { firstname: $("#firstName").val(), lastname: 
      $("#lastName").val(), productname: $("#product").val(),
      quantity: parseInt($("#quantity").jqxNumberInput('decimal')), 
      price: parseFloat($("#price").jqxNumberInput('decimal'))
    };
    var b = $('#jqxgrid').jqxGrid('addrow', null, row);
    var grid = $("#jqxGrid");
    if (b) {
       var rowid = $('#jqxGrid').jqxGrid('getselectedrowindex');
       $("#jqxGrid").jqxGrid('selectRow', rowid);
    };

    The problem is, the select row call isn’t working properly, and
    I don’t know what the right syntax is. Can you help?


    dlinstedt
    Participant

    Never mind, i found the problem. Here’s the code that works…

    The problem was 1) I used ID of “jqxGrid” when my object id actually is: “jqxgrid” lower case.
    I kept getting an ID not found error – (my own fault).
    I also had to switch the code around:

     var row = { firstname: $("#firstName").val(), lastname: $("#lastName").val(), productname: $("#product").val(),
     quantity: parseInt($("#quantity").jqxNumberInput('decimal')), price: parseFloat($("#price").jqxNumberInput('decimal'))
     };
     $("#popupWindow").jqxWindow('hide');
     var b = $('#jqxgrid').jqxGrid('addrow', null, row);
     if (b) {
        var rows = $('#jqxgrid').jqxGrid('getrows');
        $("#jqxgrid").jqxGrid('selectrow',rows.length-1);
        $("#jqxgrid").jqxGrid('ensurerowvisible',rows.length-1);
     };

    I had to close the popup window so HTML could “focus” properly, and the grid could scroll properly.

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

You must be logged in to reply to this topic.