PDA

View Full Version : Problem with store :(



vitalka
20 Apr 2011, 5:18 AM
Hi everyone, dont know where to write, so i write here my problem. P.S - im working in rails 2.3.10 & extJS 3

I have 3 tables : questions, answers and relation table between them called inquiries. So i want if i click on question I get answers only on this question. Now, if i click i get ALL answers. How to do this? My code below:

and p.s - there are two different files.

admin.js


var answers_datastore = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: '/answers?format=ext_json',
method: 'GET'}),
reader: new Ext.data.JsonReader({
root: 'answers',
id: 'id',
totalProperty: 'results'
},[
{name: 'id', mapping: 'answer.id'},
{name: 'inquiry_id', mapping: 'answer.inquiry_id'},
{name: 'text', mapping: 'answer.text'}
])
});



var answersGrid = new Ext.grid.GridPanel({
id: 'answers_grid',
store: answers_datastore,
columns: [
{id: 'text', header: "Answer ↓", width: 200, sortable: true, dataIndex: 'text'}
],
stripeRows: true,
title:'Answers'
});+ question.js (ext_scaffold) - rowclick


'rowselect': function(sm, row, rec) {


Ext.getCmp('answers_grid').store.load();
}

Screamy
20 Apr 2011, 5:27 AM
If I understand you correctly, I think you want something like this:



rowselect: function(sm, row, rec) {
Ext.getCmp('answers_grid').store.load({
params: {
inquiry_id: rec.get('id');
}
});
}

vitalka
20 Apr 2011, 5:37 AM
Thanks for fast response, but it doesn't work for me, Still if i click i get ALL answers, and i need just if I click on row (any) i get answers only for this question that i clicked.

and p.s - there are two different files.

Screamy
20 Apr 2011, 6:24 AM
Your server-side code must accept an inquiry_id parameter, then return filtered data if the parameter is not null.