damien
27 May 2007, 5:07 AM
I have a gridpanel, with a grid. Loading the page in FF the first time is OK. the second time it doesn't show the loadMask. In IE explorer the first time OK, the second time i load the page it gives a error and doesnt show the grid. Removing the
loadMask:true
in the grid fixes the problem. Everything works fine, but i want my loadMask :-)
<script type="text/javascript">
Ext.onReady(function(){
var ds;
var columnModel;
var grid;
function dialog_win(titel,boodschap,melding){
var regels;
regels=true;
if ((melding.length==0) || (melding==null)) regels=false;
var boodschap = Ext.MessageBox.show({
title: titel,
msg: boodschap,
width:300,
buttons: Ext.MessageBox.OK,
multiline: false,
value:melding,
multiline:regels
});
}
function setupDataSource() {
ds = new Ext.data.Store({
baseParams: {parameter: '<?php echo $_POST[parameter];?>'},
proxy: new Ext.data.HttpProxy({url:'http://localhost:80/PSA_Finance/get_handlers/get_dealers.php'}),
reader: new Ext.data.JsonReader(
{root: 'records',totalProperty: 'aantal', id: 'sleutel'},
[
{name: 'sleutel'},
{name: 'dealernr'},
{name: 'DA'},
{name: 'rayon'},
{name: 'b_naam'},
{name: 'b_adres'},
{name: 'b_postcode'},
{name: 'b_plaats'},
{name: 'b_postbus'},
{name: 'b_postcode_pb'},
{name: 'b_plaats_pb'},
{name: 'b_telefoonnr'}
]
)
}
);
}
function getColumnModel() {
if(!columnModel) {
columnModel = new Ext.grid.ColumnModel(
[{
header: "DealerNr",
dataIndex: 'dealernr',
sortable: true,
width: 50
},{
header: "DA",
sortable: true,
dataIndex: 'DA',
width: 25
},{
header: "Rayon",
sortable: true,
dataIndex: 'rayon',
width: 40
},{
header: "Bedrijf",
sortable: true,
dataIndex: 'b_naam',
width: 200
},{
header: "Adres",
sortable: true,
dataIndex: 'b_adres',
width: 150
},{
header: "Postcode",
sortable: true,
dataIndex: 'b_postcode',
width: 65
},{
header: "Plaats",
sortable: true,
dataIndex: 'b_plaats',
width: 85
},{
header: "Postbus",
hidden:true,
sortable: true,
dataIndex: 'b_postbus',
width: 85
},{
header: "Postcode postbus",
hidden:true,
sortable: true,
dataIndex: 'b_postcode_pb',
width: 85
},{
header: "Plaats postbus",
hidden:true,
sortable: true,
dataIndex: 'b_plaats_pb',
width: 85
},{
header: "Telefoonnr",
hidden:true,
sortable: true,
dataIndex: 'b_telefoonnr',
width: 85
}]
);
}
}
function buildGrid() {
grid = new Ext.grid.Grid('div-laden',
{
ds: ds,
cm: columnModel,
autoSizeColumns: false,
loadMask:true <-removing this and i can load this script multiple times without problems.
}
);
grid.on("rowdblclick", function(grid) {
alert(grid.getSelectionModel().getSelected().data.b_naam);
});
grid.render();
var gridFoot = grid.getView().getFooterPanel(true);
var paging = new Ext.PagingToolbar(gridFoot, ds, {
pageSize: 25,
displayInfo: true,
displayMsg: 'Onderwerpen {0} - {1} van {2}',
emptyMsg: "Geen records"
});
paging.add('-', 'Filter: ');
var filter = Ext.get(paging.addDom({
tag: 'input'
, type: 'text'
, size: '20'
, value: ''
, cls: 'x-grid-filter'
}).el);
paging.add('-');
var excel = paging.addButton({
icon: 'images/excel.gif',
minWidth:'16',
tooltip:'Export naar excel',
cls:"x-btn-icon"
});
excel.on('click',function(E){
var fil2 = filter.getValue();
dialog_win('Excel export',"Klik op onderstaand plaatje om de excelsheet te openen.<table align=center><tr><td align=center><a href=http://localhost:80/PSA_Finance/get_handlers/excel.php?filter="+fil2.replace(" ","%20")+"¶meter=<?php echo $_POST[parameter];?> target=_self><img src=images/excel.jpg align=center></a></td></tr></table>",'');
});
filter.on('keypress', function(e) { // setup an onkeypress event handler
if(e.getKey() == e.ENTER) // listen for the ENTER key
ds.load({ // call the load() method of your datastore
params: {
start: 0 // reset the start to 0 since you want the filtered results to start from the first page
, limit: 25
}
});
});
filter.on('keyup', function(e) { // setup an onkeyup event handler
var key = e.getKey(); // assign the current key to a local variable
if((key == e.BACKSPACE || key == e.DELETE) && this.getValue().length == 0) // listen for the BACKSPACE or DELETE keys and the field being empty
ds.load({ // call the load() method of your datastore
params: {
start: 0 // reset the start to 0 since you want unfiltered results to start from the first page
, limit: 25
}
});
});
filter.on('focus', function(){this.dom.select();}); // setup an onfocus event handler to cause the text in the field to be selected
ds.on('beforeload', function() {
ds.baseParams = { // modify the baseParams setting for this request
filter: filter.getValue(), // retrieve the value of the filter input and assign it to a property named filter (rename to suit your needs)
parameter: '<?php echo $_POST[parameter];?>'
};
});
ds.load({params:{start:0,limit:25}});
}
setupDataSource();
getColumnModel();
buildGrid();
innerLayout.add('center', new Ext.GridPanel(grid, {title: 'Dealers',autoScroll:false}));
});
</script>
loadMask:true
in the grid fixes the problem. Everything works fine, but i want my loadMask :-)
<script type="text/javascript">
Ext.onReady(function(){
var ds;
var columnModel;
var grid;
function dialog_win(titel,boodschap,melding){
var regels;
regels=true;
if ((melding.length==0) || (melding==null)) regels=false;
var boodschap = Ext.MessageBox.show({
title: titel,
msg: boodschap,
width:300,
buttons: Ext.MessageBox.OK,
multiline: false,
value:melding,
multiline:regels
});
}
function setupDataSource() {
ds = new Ext.data.Store({
baseParams: {parameter: '<?php echo $_POST[parameter];?>'},
proxy: new Ext.data.HttpProxy({url:'http://localhost:80/PSA_Finance/get_handlers/get_dealers.php'}),
reader: new Ext.data.JsonReader(
{root: 'records',totalProperty: 'aantal', id: 'sleutel'},
[
{name: 'sleutel'},
{name: 'dealernr'},
{name: 'DA'},
{name: 'rayon'},
{name: 'b_naam'},
{name: 'b_adres'},
{name: 'b_postcode'},
{name: 'b_plaats'},
{name: 'b_postbus'},
{name: 'b_postcode_pb'},
{name: 'b_plaats_pb'},
{name: 'b_telefoonnr'}
]
)
}
);
}
function getColumnModel() {
if(!columnModel) {
columnModel = new Ext.grid.ColumnModel(
[{
header: "DealerNr",
dataIndex: 'dealernr',
sortable: true,
width: 50
},{
header: "DA",
sortable: true,
dataIndex: 'DA',
width: 25
},{
header: "Rayon",
sortable: true,
dataIndex: 'rayon',
width: 40
},{
header: "Bedrijf",
sortable: true,
dataIndex: 'b_naam',
width: 200
},{
header: "Adres",
sortable: true,
dataIndex: 'b_adres',
width: 150
},{
header: "Postcode",
sortable: true,
dataIndex: 'b_postcode',
width: 65
},{
header: "Plaats",
sortable: true,
dataIndex: 'b_plaats',
width: 85
},{
header: "Postbus",
hidden:true,
sortable: true,
dataIndex: 'b_postbus',
width: 85
},{
header: "Postcode postbus",
hidden:true,
sortable: true,
dataIndex: 'b_postcode_pb',
width: 85
},{
header: "Plaats postbus",
hidden:true,
sortable: true,
dataIndex: 'b_plaats_pb',
width: 85
},{
header: "Telefoonnr",
hidden:true,
sortable: true,
dataIndex: 'b_telefoonnr',
width: 85
}]
);
}
}
function buildGrid() {
grid = new Ext.grid.Grid('div-laden',
{
ds: ds,
cm: columnModel,
autoSizeColumns: false,
loadMask:true <-removing this and i can load this script multiple times without problems.
}
);
grid.on("rowdblclick", function(grid) {
alert(grid.getSelectionModel().getSelected().data.b_naam);
});
grid.render();
var gridFoot = grid.getView().getFooterPanel(true);
var paging = new Ext.PagingToolbar(gridFoot, ds, {
pageSize: 25,
displayInfo: true,
displayMsg: 'Onderwerpen {0} - {1} van {2}',
emptyMsg: "Geen records"
});
paging.add('-', 'Filter: ');
var filter = Ext.get(paging.addDom({
tag: 'input'
, type: 'text'
, size: '20'
, value: ''
, cls: 'x-grid-filter'
}).el);
paging.add('-');
var excel = paging.addButton({
icon: 'images/excel.gif',
minWidth:'16',
tooltip:'Export naar excel',
cls:"x-btn-icon"
});
excel.on('click',function(E){
var fil2 = filter.getValue();
dialog_win('Excel export',"Klik op onderstaand plaatje om de excelsheet te openen.<table align=center><tr><td align=center><a href=http://localhost:80/PSA_Finance/get_handlers/excel.php?filter="+fil2.replace(" ","%20")+"¶meter=<?php echo $_POST[parameter];?> target=_self><img src=images/excel.jpg align=center></a></td></tr></table>",'');
});
filter.on('keypress', function(e) { // setup an onkeypress event handler
if(e.getKey() == e.ENTER) // listen for the ENTER key
ds.load({ // call the load() method of your datastore
params: {
start: 0 // reset the start to 0 since you want the filtered results to start from the first page
, limit: 25
}
});
});
filter.on('keyup', function(e) { // setup an onkeyup event handler
var key = e.getKey(); // assign the current key to a local variable
if((key == e.BACKSPACE || key == e.DELETE) && this.getValue().length == 0) // listen for the BACKSPACE or DELETE keys and the field being empty
ds.load({ // call the load() method of your datastore
params: {
start: 0 // reset the start to 0 since you want unfiltered results to start from the first page
, limit: 25
}
});
});
filter.on('focus', function(){this.dom.select();}); // setup an onfocus event handler to cause the text in the field to be selected
ds.on('beforeload', function() {
ds.baseParams = { // modify the baseParams setting for this request
filter: filter.getValue(), // retrieve the value of the filter input and assign it to a property named filter (rename to suit your needs)
parameter: '<?php echo $_POST[parameter];?>'
};
});
ds.load({params:{start:0,limit:25}});
}
setupDataSource();
getColumnModel();
buildGrid();
innerLayout.add('center', new Ext.GridPanel(grid, {title: 'Dealers',autoScroll:false}));
});
</script>