Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grid updateRow() fails when called for rows after an expanded row #721

Open
mihailboev opened this issue Mar 7, 2023 · 0 comments
Open

Comments

@mihailboev
Copy link

mihailboev commented Mar 7, 2023

Steps to reproduce:

  1. Create a grid with local data source and configured detailTemplate
  2. Fill with 3 elements
  3. Expand the details for the second row
  4. Call updateRow() for the third row

Expected: Third row is updated properly

Observed: Third row "data-position" attribute is set to "4". Calling updateRow() for the same row will result in a new row being inserted.

Seems to be caused by updateRow() using $row.index() when calling renderRow()

Code to reproduce:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Example</title>
  <script src="/Areas/Development/dist/libraries/jquery/jquery.js"></script>
  <script src="/Areas/Development/dist/modular/js/core.js" type="text/javascript"></script>
  <link href="/Areas/Development/dist/modular/css/core.css" rel="stylesheet" type="text/css">
  <link href="/Areas/Development/dist/modular/css/grid.css" rel="stylesheet" type="text/css">
  <script src="/Areas/Development/dist/modular/js/grid.js"></script>
</head>
<body style="padding: 8px;">
 <button onclick="editRow3()" class="gj-button-md">Edit Row 3</button>
 <br/><br/>
 <table id="grid"></table>
 <script>
   var data = [
                { 'ID': 1, 'Name': 'Hristo Stoichkov', 'PlaceOfBirth': 'Plovdiv, Bulgaria' },
                { 'ID': 2, 'Name': 'Ronaldo Luís Nazário de Lima', 'PlaceOfBirth': 'Rio de Janeiro, Brazil' },
                { 'ID': 3, 'Name': 'David Platt', 'PlaceOfBirth': 'Chadderton, Lancashire, England' }
            ];
   
     var grid = $('#grid').grid({
         dataSource: data,
         detailTemplate: '<div style="text-align: left"><b>Place Of Birth:</b> {PlaceOfBirth}</div>',
         columns: [ { field: 'ID', width: 56 }, { field: 'Name' }, { field: 'DateOfBirth', type: 'date' } ],
     });
   
   function editRow3() {
     var item = data[2];
     item.Name += '*';
     grid.updateRow(item.ID, item);
   }
 </script>
</body>
</html>
@mihailboev mihailboev changed the title Grid updateRow fails when called for rows after an expanded row Grid updateRow() fails when called for rows after an expanded row Mar 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant