User 5842 User 5842 - 4 days ago 4x
Ajax Question

Pass extJs Grid Value to Store PHP Script

I currently have a simple extJS Grid which is pulling data from a server and presenting it to the viewer. I would like to grab the value of the selected row, and then pass it to another PHP script for processing in order to display the results in another grid.

var roleInformationStore = Ext.create('', {
autoLoad: true,
autoSync: true,
model: 'RoleInformation',
proxy: {
type: 'ajax',
url: 'data.php',
reader: {
type: 'array',
writer: {
type: 'json'

var roleInformationGrid = Ext.create('Ext.grid.Panel', {
store: roleInformationStore,
width: '100%',
height: 200,
title: 'Roles',
columns: [
text: 'Name',
flex: 1,
width: 100,
sortable: false,
hideable: false,
dataIndex: 'role'
listeners: {
cellclick: function(view, td, cellIndex, record, tr, rowIndex, e, eOpts) {
roleInformationStore.proxy.extraParams = record.get('role');
//Ext.Msg.alert('Selected Record', 'Name: ' + record.get('role'));

Using the listener in the current grid, I am able to get the value and show it using the alert method. Any suggestions on how to accomplish this?



For this to work, extraParams has to be an object of key-value string pairs, because an URI has to be something like data.php?key1=value1&key2=value2.

Style-wise, Sencha advises to use getters and setters, whenever possible.

Together, you get:

var store = Ext.getStore("roleInformationStore");

In PHP, you would get the parameter then using

$role = $_GET['myRoleParamKey'];

You can of course substitute myRoleParamKey for any alphanumeric literal you want, but make sure you use the same key on both server and client side. ;-)

Docs: setExtraParam