PDA

View Full Version : undefined is null or not an object ext-all-debug.js line no : 44188



satya1974
7 Apr 2011, 10:30 AM
<code>
Ext.onReady(function(){
var myPageSize = 10;

// shorthand alias
var fm = Ext.form, Ed = Ext.grid.GridEditor;

//we enable the QuickTips for the later Pagebar
Ext.QuickTips.init();

function formatBoolean(value){
return value ? 'Yes' : 'No';
}

function formatDate(value){
return value ? value.dateFormat('M d, Y') : '';
}

/************************************************************
* Display the result in page
* the column model has information about grid columns
* dataIndex maps the column to the specific data field in
* the data store (created below)
************************************************************/
var cm = new Ext.grid.ColumnModel([{
id: 'publisher_id',
header: "PublisherID",
hidden: true,
width: 160,
sortable: true,
locked: false,
dataIndex: 'publisherId'
}, {
id: 'external',
header: "No",
width: 100,
sortable: true,
dataIndex: 'external'
}, {
id: 'company',
header: "Company",
width: 155,
sortable: true,
dataIndex: 'name'
}, {
header: "State",
width: 155,
sortable: true,
dataIndex: 'state'
}, {
header: "Zip Code",
width: 155,
sortable: true,
dataIndex: 'zip'
}
]);

// by default columns are sortable
cm.defaultSortable = false;
// this could be inline, but we want to define the NewAccount record
// type so we can add records dynamically
var Publisher = Ext.data.Record.create([{
name: 'publisherId',
type: 'int'
}, {
name: 'name',
type: 'string'
}, {
name: 'state',
type: 'string'
}, {
name: 'zip',
type: 'string'
}, {
name: 'external',
type: 'string'
}]);
/************************************************************
* connect to backend - grid - core part
* create the Data Store
* connect with backend and list the result in page
* through JSON format
************************************************************/
var ds = new Ext.data.Store({
// load using script tags for cross domain, if the data in on the same domain as
// this page, an HttpProxy would be better
proxy: new Ext.data.HttpProxy({
url: 'publisher/view.action'
}),
// create reader that reads the Topic records
reader: new Ext.data.JsonReader({
root: 'data',
totalProperty: 'total',
id: 'publisherId'
}, [
{name: 'external'},
{name: 'name'},
{name: 'state'},
{name: 'zip'}
]),
// turn on remote sorting
remoteSort: true
});
ds.setDefaultSort('name', 'ASC');
// create the editor grid
var grid = new Ext.grid.GridPanel('editor-grid', {
ds: ds,
cm: cm
});
var layout = Ext.BorderLayout.create({
center: {
margins:{left:2,top:3,right:2,bottom:3},
panels: [new Ext.GridPanel(grid)]
}
}, 'grid-panel');
// render it
grid.render();

/************************************************************
* create header panel
* add filter field - search function
************************************************************/
var gridHead = grid.getView().getHeaderPanel(true);
var tb = new Ext.Toolbar(gridHead);

filterButton = new Ext.Toolbar.MenuButton({
icon: 'public/image/list-items.gif',
cls: 'x-btn-text-icon',
text: 'Choose Filter',
tooltip: 'Select one of filter',
menu: {items: [
new Ext.menu.CheckItem({ text: 'Company', value: 'name', checked: true, group: 'filter', checkHandler: onItemCheck }),
new Ext.menu.CheckItem({ text: 'State', value: 'external', checked: false, group: 'filter', checkHandler: onItemCheck }),
new Ext.menu.CheckItem({ text: 'Zip', value: 'zip', checked: false, group: 'filter', checkHandler: onItemCheck })
]},
minWidth: 105
});
tb.add(filterButton);

// Create the filter field
var filter = Ext.get(tb.addDom({ // add a DomHelper config to the toolbar and return a reference to it
tag: 'input',
type: 'text',
size: '30',
value: '',
style: 'background: #F0F0F9;'
}).el);
// press enter keyboard
filter.on('keypress', function(e) { // setup an onkeypress event handler
if(e.getKey() == e.ENTER && this.getValue().length > 0) {// listen for the ENTER key
ds.load({params:{start:0, limit:myPageSize}});
}
});

filter.on('keyup', function(e) { // setup an onkeyup event handler
if(e.getKey() == e.BACKSPACE && this.getValue().length === 0) {// listen for the BACKSPACE key and the field being empty
ds.load({params:{start:0, limit:myPageSize}});
}
});

// Update search button text with selected item
function onItemCheck(item, checked)
{
if(checked) {
filterButton.setText(item.text + ':');
}
}
/************************************************************
* create footer panel
* actions and paging
************************************************************/
var gridFoot = grid.getView().getFooterPanel(true);
// add a paging toolbar to the grid's footer
var paging = new Ext.PagingToolbar(gridFoot, ds, {
pageSize: myPageSize,
displayInfo: true,
displayMsg: 'total {2} results found. Current shows {0} - {1}',
emptyMsg: "not result to display"
});

/************************************************************
* load parameter to backend
* have beforelaod function
************************************************************/
ds.on('beforeload', function() {
ds.baseParams = { // modify the baseParams setting for this request
filterValue: filter.getValue(),// retrieve the value of the filter input and assign it to a property named filter
filterTxt: filterButton.getText()
};
});
// trigger the data store load
ds.load({params:{start:0, limit:myPageSize}});
});

</code>

Anyhelp is highly appreciated. I am using extjs 3.2.

Json Data:

var data =[
[1,'abc','3m Co'],
[2,'efg','xyz'],
]

fay
7 Apr 2011, 11:43 AM
Nearly impossible to read that; can you edit your post and add CODE (http://www.sencha.com/learn/Ext_Forum_Help) tags.

Additionally, post a sample of your JSON data for testing.