Charan Vuyyuru
Charan Vuyyuru

Reputation: 13

Extjs on load Sort

Folks,

I am developing a Visualforce page with ExtJS Grid in it.

Is there any method to sort the specific grid column to ASC or DESC?

I am using ExtJS 3.2.

Thanks in Advance.

Upvotes: 1

Views: 5865

Answers (1)

dougajmcdonald
dougajmcdonald

Reputation: 20037

In order to sort the grid, it will have options in the column headers to allow a user to sort. If you want to do it programatically I believe you need to sort the 'store' which the grid is bound to.

You can then specify a sort config on the store (if you want default sorting on initial load) e.g.

sortInfo: {
    field: 'fieldName',
    direction: 'ASC' // or 'DESC' (case sensitive for local sorting)
}

other that the sort info config on the store, you can explicitely call the 'sort' method on the store passing through a fieldname and direction e.g.

theStore.sort({
   field    : 'salary',
   direction: 'DESC'
});

Upvotes: 2

Related Questions