function Example4(com, grid) { if (com == 'Delete') { var conf = confirm('Delete ' + $('.trSelected', grid).length + ' items?') if(conf){ $.each($('.trSelected', grid), function(key, value){ $.get('example4.php', { Delete: value.firstChild.innerText} , function(){ // when ajax returns (callback), update the grid to refresh the data $(".flexme4").flexReload(); }); }); } } else if (com == 'Edit') { var conf = confirm('Edit ' + $('.trSelected', grid).length + ' items?') if(conf){ $.each($('.trSelected', grid), function(key, value){ // collect the data var OrgEmpID = value.children[0].innerText; // in case we're changing the key var EmpID = prompt("Please enter the New Employee ID",value.children[0].innerText); var Name = prompt("Please enter the Employee Name",value.children[1].innerText); var PrimaryLanguage = prompt("Please enter the Employee's Primary Language",value.children[2].innerText); var FavoriteColor = prompt("Please enter the Employee's Favorite Color",value.children[3].innerText); var FavoriteAnimal = prompt("Please enter the Employee's Favorite Animal",value.children[4].innerText);
// call the ajax to save the data to the session $.get('example4.php', { Edit: true , OrgEmpID: OrgEmpID , EmpID: EmpID , Name: Name , PrimaryLanguage: PrimaryLanguage , FavoriteColor: FavoriteColor , FavoritePet: FavoriteAnimal } , function(){ // when ajax returns (callback), update the grid to refresh the data $(".flexme4").flexReload(); }); }); } } else if (com == 'Add') { // collect the data var EmpID = prompt("Please enter the Employee ID","5"); var Name = prompt("Please enter the Employee Name","Mark"); var PrimaryLanguage = prompt("Please enter the Employee's Primary Language","php"); var FavoriteColor = prompt("Please enter the Employee's Favorite Color","Tan"); var FavoriteAnimal = prompt("Please enter the Employee's Favorite Animal","Dog");
// call the ajax to save the data to the session $.get('example4.php', { Add: true, EmpID: EmpID, Name: Name, PrimaryLanguage: PrimaryLanguage, FavoriteColor: FavoriteColor, FavoritePet: FavoriteAnimal } , function(){ // when ajax returns (callback), update the grid to refresh the data $(".flexme4").flexReload(); }); } } </script>
Pergunta
JoeJr
Bom dia !
tenho um flexigrid que me retorna alguns dados via XML, porém o mesmo não faz a paginação.
Consigo apenas mudar de página manualmente, direto na Query, onde eu altero o numero da pagina e o LIMIT.
Query :
$page = 1;
if (!$rp) $rp = 100;
$start = (($page-1) * $rp);
$limit = "LIMIT $start, $rp";
$stringSQL = "select $exibicao from $tabela $Where $orderBy $limit";
Flexigrid:
<table class='flexme4' id="flex1" style="display:none"></table>
<script type="text/javascript">
$(".flexme4").flexigrid({
url : '/corporativo/servicos/bi/<?php echo $urlRequireAjax; ?>consultaBS.php?id_file=<?php echo $_GET['id_file']; ?>',
dataType : 'json',
colModel : [
<?php
//descobre título das colunas no select montado
$elementoExibe = $doc->getElementsByTagName("condicaoExibicao")->item(0)->childNodes;
$e="";
$a=0;
foreach($elementoExibe as $condExibe){
$titulo = utf8_decode($condExibe->getAttribute('tituloColuna'));
$codigo = explode("_",$condExibe->tagName);
if($a == 0){
$e.= "{display: '$titulo', name : '".$codigo[1]."', width : 80, sortable : false, align: 'left'}\r\n";
} else {
$e.= ",{display: '$titulo', name : '".$codigo[1]."', width : 80, sortable : false, align: 'left'}\r\n";
}
$a++;
}
echo $e;
?>
],
buttons : [
// {
// name : 'Add',
// bclass : 'add',
// onpress : Example4
// }
// ,
// {
// name : 'Edit',
// bclass : 'edit',
// onpress : Example4
// }
// ,
// {
// name : 'Delete',
// bclass : 'delete',
// onpress : Example4
// }
// ,
// {
// separator : true
// }
],
//searchitems : [
// {
// display : 'EmployeeID',
// name : 'employeeID'
// }, {
// display : 'Name',
// name : 'name',
// isdefault : true
// }
//],
sortname: "<?php echo $_SESSION['ordenacao']; ?>",
sortorder : "asc",
usepager : true,
title: 'Resultado da consulta SQL',
useRp : true,
rp : 100,
showTableToggleBtn : false,
width : 970,
height : 343
});
function Example4(com, grid) {
if (com == 'Delete') {
var conf = confirm('Delete ' + $('.trSelected', grid).length + ' items?')
if(conf){
$.each($('.trSelected', grid),
function(key, value){
$.get('example4.php', { Delete: value.firstChild.innerText}
, function(){
// when ajax returns (callback), update the grid to refresh the data
$(".flexme4").flexReload();
});
});
}
}
else if (com == 'Edit') {
var conf = confirm('Edit ' + $('.trSelected', grid).length + ' items?')
if(conf){
$.each($('.trSelected', grid),
function(key, value){
// collect the data
var OrgEmpID = value.children[0].innerText; // in case we're changing the key
var EmpID = prompt("Please enter the New Employee ID",value.children[0].innerText);
var Name = prompt("Please enter the Employee Name",value.children[1].innerText);
var PrimaryLanguage = prompt("Please enter the Employee's Primary Language",value.children[2].innerText);
var FavoriteColor = prompt("Please enter the Employee's Favorite Color",value.children[3].innerText);
var FavoriteAnimal = prompt("Please enter the Employee's Favorite Animal",value.children[4].innerText);
// call the ajax to save the data to the session
$.get('example4.php',
{ Edit: true
, OrgEmpID: OrgEmpID
, EmpID: EmpID
, Name: Name
, PrimaryLanguage: PrimaryLanguage
, FavoriteColor: FavoriteColor
, FavoritePet: FavoriteAnimal }
, function(){
// when ajax returns (callback), update the grid to refresh the data
$(".flexme4").flexReload();
});
});
}
}
else if (com == 'Add') {
// collect the data
var EmpID = prompt("Please enter the Employee ID","5");
var Name = prompt("Please enter the Employee Name","Mark");
var PrimaryLanguage = prompt("Please enter the Employee's Primary Language","php");
var FavoriteColor = prompt("Please enter the Employee's Favorite Color","Tan");
var FavoriteAnimal = prompt("Please enter the Employee's Favorite Animal","Dog");
// call the ajax to save the data to the session
$.get('example4.php', { Add: true, EmpID: EmpID, Name: Name, PrimaryLanguage: PrimaryLanguage, FavoriteColor: FavoriteColor, FavoritePet: FavoriteAnimal }
, function(){
// when ajax returns (callback), update the grid to refresh the data
$(".flexme4").flexReload();
});
}
}
</script>
Já olhei no console e não há erros.
Origado desde já!
Editado por JoeJrLink para o comentário
Compartilhar em outros sites
1 resposta a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.