PDA

View Full Version : Table/grid Title dynamically assigned



softwareplay
19 Sep 2013, 2:22 AM
The operation I want to do is not easy.I have a first grid (or table) and a secondo one, generated clicking on a cell which is present in every row of the first table. It takes the parameters of the first table and shows some other content of the json which generates the tables.

The second table is included in a column of the first table, it is made by an ajax call and:


Ext.create('Ext.window.Window' etc. etc.

The Problem is that i want to take the name of the row of the first table an use it as the name of the second table, which is inside the first. I've found some useful advices (1 (http://stackoverflow.com/questions/11186682/getting-raw-value-of-a-cell-of-a-selected-row-in-a-grid), 2 (http://stackoverflow.com/questions/2447401/how-to-read-and-set-a-value-of-a-specific-cell-in-an-extjs-grid)) but the work for the "current" table, not for my specific case. Anyone can help?

The code i use is below:


var grid = Ext.create('Ext.ux.LiveSearchGridPanel', {
store: store1,
stateful: true,
collapsible: true,
multiSelect: true,
stateId: 'stateGrid',
columns: [
{
text : 'id',
flex : 1,
sortable : true,
dataIndex: 'id'
},
{
text : 'buyer_member_id',
width : 75,
sortable : true,
dataIndex: 'buyer_member_id'
},
{
text : 'Client Name',
width : 200,
sortable : true,
dataIndex: 'name'
},
{
xtype : 'actioncolumn',
width : '5%',
sortable : false,
items : [{
icon : '../static/accept.gif',
tooltip : 'See Admants',
handler : function(grid, rowIndex, colIndex){
var row = grid.getStore().getAt(rowIndex);
var buyer_member_id = row.data.buyer_member_id;
Ext.Ajax.defaultHeaders = {
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
};
Ext.Ajax.request({
method : "GET",
url: '/admants/?buyer_member_id='+ buyer_member_id,
success : function(response) {
var obj = response;
try {
obj = Ext.decode(response.responseText);
} catch (error) {alert("Errore nella decodifica del file json");}
if (obj) {
Ext.define('Admants', {
extend: 'Ext.data.Model',
fields: [
{name: 'id', type: 'int', convert: null, defaultValue:undefined},
{name: 'name', type: 'string', convert:null, defaultValue:undefined},
{name: 'group', type: 'string', convert:null, defaultValue:undefined}
],
idProperty: 'id'
});
var groupingFeature = Ext.create('Ext.grid.feature.Grouping',{
groupHeaderTpl: 'Group: {name} ({rows.length} Item{[values.rows.length > 1 ? "s" : ""]})'
});
var Admantstore = Ext.create('Ext.data.Store', {
autoLoad: true,
storeId: 'Admants',
sorters: ['id', 'name','group'],
groupField: 'group',
fields: ['id','name','group'],
data : obj,
model: 'Admants',
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'admants'
}
}
});
Ext.create('Ext.window.Window', {
title: 'Admants', //this line has to be changed
height: 200,
width: 400,
layout: 'fit',
items: {
xtype: 'grid',
border: false,
store: Admantstore,
features: [groupingFeature],
columns: [
{
text : 'id',
flex : 1,
sortable : true,
dataIndex: 'id'
},
{
text : 'name',
width : 300,
sortable : true,
dataIndex: 'name'
}],
}}).show();
} else {
alert("Invalid response");
}
},
failure : function(response) {
alert("Data request failed");
}
});
}
}]
}
],
height: 350,
width: 600,
title: 'Member Data Sharing',
renderTo: 'grid-example1',
viewConfig: {
stripeRows: true,
enableTextSelection: true
}
});
});

softwareplay
20 Sep 2013, 2:13 AM
In this (http://stackoverflow.com/questions/18891753/getting-a-value-from-a-parent-grid-use-it-as-title-in-the-child-grid-ext-js-4) web page is described the solution of this problem

Gary Schlosberg
21 Sep 2013, 3:34 PM
Thanks for giving back to the community by posting your solution.