hkalbertl / jquery.appendGrid

The dynamic table input JavaScript plugin
https://appendgrid.azurewebsites.net
MIT License
148 stars 76 forks source link

[BUG] getRowValue documentation-implementation mismatch #131

Closed scrnjakovic closed 4 years ago

scrnjakovic commented 4 years ago

Documentation says that getRowValue accepts rowIndex as an argument, when in reality it wants uniqueIndex.

Is this the error of documentation or implementation?

Try following code taken from the demo page:

var myAppendGrid = new AppendGrid({
  element: "tblAppendGrid",
  uiFramework: "bootstrap4",
  iconFramework: "fontawesome5",
  columns: [
    {
      name: "col-1",
      display: "Column 1",
      ctrlAttr: { placeholder: "Click me!" },
      events: {
        click: function(e) {
          var rowIndex = myAppendGrid.getRowIndex(parseInt(e.uniqueIndex));
          console.log("Using RowIndex");
          console.log(myAppendGrid.getRowValue(rowIndex));
          console.log("Using UniqueIndex");
          console.log(myAppendGrid.getRowValue(e.uniqueIndex));
        }
      }
    },
    {
      name: "col-2",
      display: "Column 2",
      ctrlAttr: { placeholder: "Mouseover me!" },
      events: {
        mouseover: function(e) {
          e.target.style.backgroundColor = "#FF9999";
        },
        mouseout: function(e) {
          e.target.style.backgroundColor = null;
        }
      }
    },
    {
      name: "col-3",
      display: "Column 3",
      ctrlAttr: { placeholder: "Key in something..." },
      events: {
        change: function(e) {
          if (e.target.value) {
            e.target.style.backgroundColor = "#99FF99";
          } else {
            e.target.style.backgroundColor = null;
          }
        }
      }
    }
  ]
});

Type something in column3 of row1 and then click on the column1 of row1 or row2.

hkalbertl commented 4 years ago

Hi scrnjakovic,

It is a bug on using rowIndex internally. This problem in fixed in v2-dev branch now. I will do some more testing and publish a new release soon. Thanks!

hkalbertl commented 4 years ago

Hi, the problem is fixed in 2.0.6. Please try again. Thanks!

scrnjakovic commented 4 years ago

Fixed. Thanks :)