I want to show certain data from a MySql table to ExtJs Datagrid.using PHP.
I have searched alot but there are no threads on this topic
I found one but with ExtJs 2
Printable View
I want to show certain data from a MySql table to ExtJs Datagrid.using PHP.
I have searched alot but there are no threads on this topic
I found one but with ExtJs 2
Hope you have gone through examples - http://docs.sencha.com/ext-js/4-0/#!/example/grid/array-grid.html
Below is a small sample hoping that you are looking for the same:
Hope this helps.Code:
//Define the model below, map the fields in your JSON coming from the server to the field names in this model
Ext.define('GridModel', {
extend: 'Ext.data.Model',
fields: [
{name: 'company', type: 'string'},
{name: 'price', type: 'string'},
{name: 'change', type: 'string'},
{name: 'pctChange', type: 'string'}
]
});
//Define the store below, providing it the Model and the URL of PHP file
var storeVar = Ext.create('Ext.data.Store', {
pageSize: 5,
model: 'GridModel',
proxy: {
type: 'ajax',
url : 'stores_page_grid.php',
reader: {
type: 'json'
},
extraParams:{
action:'pagingTestGrid'
}
},
autoLoad: false
});
// create the Grid
var grid = Ext.create('Ext.grid.Panel', {
id:'gridId',
store: storeVar,
columns: [
{
text : 'Company',
flex : 1,
sortable : false,
dataIndex: 'company'
},
{
text : 'Price',
width : 75,
sortable : true,
dataIndex: 'price'
},
{
text : 'Change',
width : 75,
sortable : true,
dataIndex: 'change'
},
{
text : '% Change',
width : 75,
sortable : true,
dataIndex: 'pctChange'
}
],
// paging bar on the bottom
bbar: Ext.create('Ext.PagingToolbar', {
store: storeVar,
displayInfo: true,
displayMsg: 'Displaying topics {0} - {1} of {2}',
emptyMsg: "No topics to display"
}),
height: 350,
width: 600,
title: 'Array Grid',
renderTo: 'grid-example',
viewConfig: {
stripeRows: true
}
});
I need example with PHP + Mysql not jason
Thank you but I need example with PHP + Mysql not jason
You can use PHP script to query data from mySQL and use json_encode to return that data.