DonnieCrump
DonnieCrump

Reputation: 169

Get/Set igGrid combo cell value

I have an iggrid that is using a JSON data source for the main grid data and the combo box in one of my fields.

I have created the grid and the combo and the data is there. When I change the combo value and commit the grid the main grid column value does not change. I can see this by assigning a default value to the column and then changing it via a combo box.

I am working off of this example. http://www.infragistics.com/products/jquery/sample/combo-box/grid-editor

Combo Data

occCodeData = [
  { "ID": "0", "OccCode": "Food" },
  { "ID": "1", "OccCode": "Beverages" },
  { "ID": "2", "OccCode": "Electronics" },
  { "ID": "3", "OccCode": "Cookies" }
];

My grid data is stored in a JSON variable in javascript pulled from a web api. I have verified the data is valid using a console write.

Does anyone have this working with standard JSON, JS, and HTML? This main issue is when I change the combo value it does not update my JSON data behind the scenes. The GUI grid changes fine.

Upvotes: 2

Views: 3224

Answers (2)

DonnieCrump
DonnieCrump

Reputation: 169

I figured it out. My Sample occCodeData data did not match my current value.

So my default value pulled from the database was 129 but my possible values were 0,1,2,3. This was causing the combo not to change the value because it did not have a match in it's own listing.

Upvotes: 1

Konstantin Dinev
Konstantin Dinev

Reputation: 34905

When you have editing in the grid, by default the autoCommit option is set to false (meaning the UI updates but the values are not committed to the data source). You can change this to true in order to automatically commit to the data:

//Initialize
$(".selector").igGrid({
    autoCommit : true
});

//Get
var commit = $(".selector").igGrid("option", "autoCommit");

Or you can call the commit method manually:

$(".selector").igGrid("commit");

Upvotes: 1

Related Questions