PDA

View Full Version : Loading data in the gird after reading value from textbox



webfriend13
4 Mar 2012, 9:51 PM
Hi All,

I have a grid which contains only one column. I have a store which has two fields namely UserId and OrderID. I have not assigned store to the grid at the design time using Store config. There is a text box where user will enter the UserID and I need to display the OrderID for that user in the grid. Since the numbers of records are relatively low, I want to load the store only once & I have set the autoload property for the store as true. What should I wrote in order to ensure grid is populated with correct order id (for the given userid) each time user clicks on search button & there should not be any need to load data again and again. Following the the JSOn file I m using to load my store.


{
Data: [
{
UserID: "A",
OrderID: "1"
},
{
UserID : "A",
OrderID: "2"
},
{
UserID : "B",
OrderID: "3"
},
{
UserID: "A Period",
OrderID: "4"
},
{
UserID: "C",
OrderID: "5"
},
{
UserID : "A",
OrderID: "6"
},
{
UserID : "D",
OrderID: "7"
},
{
UserID: "D",
OrderID: "8"
}
]
}

Thnaks in advance.

chramer
4 Mar 2012, 10:50 PM
1. read the value from textbox

userval = textbox.getValue();
2. filter the store

store.clearFilter();
store.filter([
Ext.create('Ext.util.Filter', {property: "UserID", value : userval , root: 'data'}),
]);
3. add the store to the grid

grid.reconfigure(store);

P.S. I would recommend to bind the store with the grid at the beginning,
then you can skip step 3.