PDA

View Full Version : [CLOSED] Change a specific row cls on the fly without GetRowClass



blueworld
Aug 20, 2013, 2:12 PM
Hi,

I have a directMethod that delivers an Id in the callback.
With that Id I am able to find/select a specific row.



var find = App.GridPanelReturn.store.find('Id', result);
if (find != -1) {
App.GridPanelReturn.getView().select(find);
}


I have seen the "Marking Records" example but my store will not be changed or reloaded at that moment, so I cant use GetRowClass

The find variable is the row index, what are the next steps to apply a different cls to that row?

Daniil
Aug 20, 2013, 6:34 PM
Hi @blueworld,

You can force execution of GetRowClass by:

grid.getView().refresh();


I would recommend to do it instead of applying a CSS class of a DOM element directly, bypassing GetRowClass.

blueworld
Aug 21, 2013, 7:55 AM
Hi Daniil,

thank you.
I have added a client-side only modelField boolean, default = false




<ext:ModelField Name="IsReturned" DefaultValue="0" Type="Boolean" />


Then I want to set this property to true if an Item that is displayed in the grid has been returned, and change the color of the row.



<ext:GridView runat="server" ID="gridView2" LoadMask="true" LoadingText="Suche ausgeliehene Objekte">
<GetRowClass Fn="checkIfKeyReturned" />
</ext:GridView>




var checkIfKeyReturned = function (record) {
if (record.data.IsReturned) {
return "ObjectReturned";
}
}





var find = App.GridPanelReturn.store.find('Id', result);
if (find != -1) {
var record = App.GridPanelReturn.store.getAt(find);

record.data.IsReturned = true;

record.save();

App.GridPanelReturn.getView().refresh();
}



When calling record.save(); i get the following error:


Cannot call method 'indexOf' of undefined


What I basicly want to do:
1. Get the record at specified index
2. Set IsReturned = true
3. Save that record
4. Refresh gridView to fire GetRowClass

What I am doing wrong?

blueworld
Aug 21, 2013, 8:36 AM
Sorry my fault, this does work:



record.set("IsReturned",true)

record.commit();