David
David

Reputation: 4271

How to display Altered value in ExtJS grid

I have a grid in which I am showing data which is coming from backend. Data format is like

DESC:"H1",
DISP:"",
FID:474747,
VALUE : 0,
R:""

In this R value is not coming therefore I am setting R value from my code.

var record = gridEl.getSelectionModel().getSelections();
for (var i = 0; i < record.length; i++)
    record[i].set("R", RDetail); // RDetail is some value.

By doing this I am able to add R data into grid store as well as In debugger When I check It is displaying in UI. But when I close and refresh the grid R value is not displaying in UI.

I also have tried these

store.reload();
store.commitChange();
grid.reconfigure(store);

But displaying have some issue.

Upvotes: 1

Views: 635

Answers (2)

Harshal
Harshal

Reputation: 946

You can use renderer function for column to which parameter 'R' is assigned as dataIndex. This function will be called for each record in store so you can write your logic to show alternate value for blank R here. This will only show changed value on UI without changing it in actual store record.

Check this example http://extjs.eu/ext-grid-renderer-danger/

Upvotes: 1

fradal83
fradal83

Reputation: 2022

I can think of two other ways to do this.

  1. In the model definition, when you define the R column, you can add a "convert" function to populate that value when the data is loaded from the backend. http://docs.sencha.com/extjs/6.0.2-classic/Ext.data.field.Field.html#cfg-convert

  2. In the grid column definition, you can add a renderer function to calculare that value. http://docs.sencha.com/extjs/6.0.2-classic/Ext.grid.column.Column.html#cfg-renderer

Upvotes: 0

Related Questions