PDA

View Full Version : Cannot Display Data in GRID



aprochko
31 Oct 2011, 8:34 PM
I am using a ASP.NET Web Service JSONP to get data from a SQL Server database. The data looks ok, however, I am unable to get it to render in the Grid. The JSON data is attached. Any help is appreciated.28973



Ext.onReady(function(){
Ext.tip.QuickTipManager.init();

Ext.define('Authors', {
extend: 'Ext.data.Model',
fields: [
{name: 'userID', type: 'int'},
{name: 'fullName', type: 'string'},
{name: 'userName', type: 'string'},
{name: 'eMail', type: 'string'},
{name: 'isActive', type: 'string'}
],
idProperty: 'userID'
});

// create the Data Store
var store = Ext.create('Ext.data.Store', {
pageSize: 40,
model: 'Authors',
remoteSort: true,
proxy: {
type: 'jsonp',
url: '../../EMRWebServices/Service.asmx/getSampleSQLDataSencha',
// url: 'www.speechtodocs.com/EMRWebServices/Service.asmx/getSampleSQLDataSencha',
reader: {
totalProperty: 'd.totalCount',
root: 'd.items'
}
}
});

// pluggable renders
function renderEmail(value, p, record) {
return Ext.String.format('<a href="{1}" target="_blank">{0}</a>',
value,
record.data.link
);
}

var pluginExpanded = true;
var grid = Ext.create('Ext.grid.Panel', {
width: 700,
height: 500,
title: 'Show MTASP Authors',
store: store,
viewConfig: {
trackOver: false,
stripeRows: true
},
// grid columns
columns:[{
id: 'userid',
text: "UserID",
dataIndex: 'userid',
width: 50,
hidden: true,
sortable: false
},{
text: "Author",
dataIndex: 'fullname',
width: 200,
sortable: true
},{
text: "Username",
dataIndex: 'username',
width: 120,
align: 'left',
sortable: true
},{
text: "Email",
dataIndex: 'email',
width: 200,
renderer: renderEmail,
sortable: true
},{
text: "Active",
dataIndex: 'isActive',
width: 70,
sortable: true
}],
// paging bar on the bottom
bbar: Ext.create('Ext.PagingToolbar', {
store: store,
displayInfo: true,
displayMsg: 'Displaying topics {0} - {1} of {2}',
emptyMsg: "No topics to display",
items:[
'-', {
text: 'Show Preview',
pressed: pluginExpanded,
enableToggle: true,
toggleHandler: function(btn, pressed) {
var preview = Ext.getCmp('gv').getPlugin('preview');
preview.toggleExpanded(pressed);}
}
]
}),
renderTo: 'topic-grid'
});

// trigger the data store load
store.load;
});

poojagarg89
31 Oct 2011, 9:30 PM
I dont have idea of ASP.NET n JSONP

but m using Ajax request to fetch the data from the database and to display in the grid
if u r using ajax request for getting data from DB then u can use this code:



Ext.define('Authors', {
extend: 'Ext.data.Model',
fields: [
{name: 'userID', type: 'int'},
{name: 'fullName', type: 'string'},
{name: 'userName', type: 'string'},
{name: 'eMail', type: 'string'},
{name: 'isActive', type: 'string'}
],
idProperty: 'userID'
});
var bulletin_users_store = new Ext.data.Store({
model: 'Authors',
proxy: {
type: 'ajax',
url : 'display.do', /*the name of the action class through which ur gonna show the values */
reader: {
type: 'xml',
record: 'item'
}
}
});


m using struts so display.do is the path name in my struts for particular action class...........!!!

aprochko
1 Nov 2011, 12:26 PM
Thank you, but I'm looking for a solution in JSON

Dragonrider
4 Nov 2011, 12:08 PM
Ext.define('Authors', { extend: 'Ext.data.Model',

fields: [ {name: 'userID', type: 'int'},
{name: 'fullName', type: 'string'},
{name: 'userName', type: 'string'},
{name: 'eMail', type: 'string'},
{name: 'isActive', type: 'string'} ],

idProperty: 'userID' });

var bulletin_users_store = new Ext.data.JsonStore({
model: 'Authors',
proxy: {
type: 'ajax',
url : 'display.do', /*the name of the action class through which ur gonna show the values */
reader: {
type: 'json',
record: 'item'
}
}
});

Try this one for json...

EmegaMart20
6 Nov 2011, 6:41 AM
thanks I will try it. may be my problem solved. I hope.