EasyUI Forum

General Category => General Discussion => Topic started by: baxter on January 27, 2013, 04:37:09 PM



Title: datagrid / getPager?
Post by: baxter on January 27, 2013, 04:37:09 PM
Hello @all:

Any Ideas why this not work, i become no alert?

Code:
$('#servicegrid').datagrid({
    nowrap: false,
    striped: true,
    collapsible:true,
    url:'/manage/json.php',
    pagination: true,
    singleSelect: true,
    sortName: 'sort',
    sortOrder: 'ASC',
    fitColumns: true,
    idField:'id',
    pageSize:30,
    pageNumber: 1,
    queryParams: {"action": "service"},
    columns:[[  
{field:'id',title:'ID',width:20, sortable: 'true'},  
{field:'short',title:'Abk.', width:30, sortable: true, editor: 'text' },  
{field:'long',title:'Service', width:100, sortable: true, editor: 'text' },
{field:'dict',title:'Beschreibung', width:160, sortable: true, editor: 'text' },
        {field:'sort',title:'Sortierung', width:120, sortable: true, editor: 'numberspinner'},
        {field:'action',title:'', width:100,
        formatter:function(value,row,index){
                if(row.editing){
                    var link = '<a href="#" onclick="saverow('+index+')">Speichern</a> ';
   link += '<a href="#" onclick="cancelrow('+index+')">Abrechen</a>';
}
else {
                    var link  = '<a href="#" onclick="editrow('+index+')">Ändern</a> ';
   link += '<a href="#" onclick="deleterow('+index+')">Löschen</a>';
}
return link;
   }
        }
    ]],
    onBeforeEdit:function(index,row){    
        row.editing = true;
        updateActions(index);
    },
    onAfterEdit:function(index,row){
row.editing = false;
        updateActions(index);
    },
    onCancelEdit:function(index,row){
        row.editing = false;
        //updateActions(index);
    },
});
var p = $('#servicegrid').datagrid('getPager');
$(p).pagination({
    onBeforeRefresh:function(){
        alert('before refresh');
    }
});
$('#servicegrid').datagrid({
    nowrap: false,
    striped: true,
    collapsible:true,
    url:'/manage/json.php',
    pagination: true,
    singleSelect: true,
    sortName: 'sort',
    sortOrder: 'ASC',
    fitColumns: true,
    idField:'id',
    pageSize:30,
    pageNumber: 1,
    queryParams: {"action": "service"},
    columns:[[  
{field:'id',title:'ID',width:20, sortable: 'true'},  
{field:'short',title:'Abk.', width:30, sortable: true, editor: 'text' },  
{field:'long',title:'Service', width:100, sortable: true, editor: 'text' },
{field:'dict',title:'Beschreibung', width:160, sortable: true, editor: 'text' },
        {field:'sort',title:'Sortierung', width:120, sortable: true, editor: 'numberspinner'},
        {field:'action',title:'', width:100,
        formatter:function(value,row,index){
                if(row.editing){
                    var link = '<a href="#" onclick="saverow('+index+')">Speichern</a> ';
   link += '<a href="#" onclick="cancelrow('+index+')">Abrechen</a>';
}
else {
                    var link  = '<a href="#" onclick="editrow('+index+')">Ändern</a> ';
   link += '<a href="#" onclick="deleterow('+index+')">Löschen</a>';
}
return link;
   }
        }
    ]],
    onBeforeEdit:function(index,row){    
        row.editing = true;
        updateActions(index);
    },
    onAfterEdit:function(index,row){
row.editing = false;
        updateActions(index);
    },
    onCancelEdit:function(index,row){
        row.editing = false;
        //updateActions(index);
    },
});

var p = $('#servicegrid').datagrid('getPager');
$(p).pagination({
    onBeforeRefresh:function(){
        alert('before refresh');
    }
});


Title: Re: datagrid / getPager?
Post by: stworthy on January 27, 2013, 07:38:40 PM
Please refer to http://www.jeasyui.com/tutorial/datagrid/datagrid12.php.


Title: Re: datagrid / getPager?
Post by: baxter on January 28, 2013, 02:16:14 AM
Thanks stworthy, but i don´t have a problem with the editor in the grid. That works all fine...

My Problem ist the getPager request, that not works. I will send a queryParams request to the rest server when i click
the refresh/reload icon on the pagination panel... But the think is, with my code i become no alert back, when i click this button.

Code:
...
var p = $('#servicegrid').datagrid('getPager');
$(p).pagination({
    onBeforeRefresh:function(){
        alert('before refresh');
    }
});


Title: Re: datagrid / getPager?
Post by: stworthy on January 28, 2013, 07:07:40 PM
Please refer to http://jsfiddle.net/qJ8mJ/. This example works fine. Clicking the refresh button will display the alert window.


Title: Re: datagrid / getPager?
Post by: baxter on January 29, 2013, 02:51:25 AM
Thanks again;-)

I think i find the problem. I used tabs for the display content. When i use the Site without tabs, its getPager work, inside the tab, doesn't work.

Code:
function addTab(url, title, icon) {
   
    if ($('#tabs').tabs('exists', title)) {
        $('#tabs').tabs('select', title)
    } else {
        index++;

        $('#tabs').tabs('add', {
title: title,
href: url,
iconCls: icon,
closable: true,
border: 0,
selected: true
});
    }
}


Title: Re: datagrid / getPager?
Post by: baxter on January 30, 2013, 01:17:12 PM
no ideas why this not work inside tabs with href content?


Title: Re: datagrid / getPager?
Post by: pratikk on March 31, 2014, 11:52:35 AM
Same thing happened to me. I am using tabs and getPager doesn't work !