PDA

View Full Version : Combo Pagination problem



Nexus3
22 Feb 2011, 1:08 AM
Hi, first sorry because my english is no long....

I've a problem, i´m trying to paginate a combobox, i can view the results of the first pagination ok, but when i pulse the button to see the next results, the box with the the first results automatic is closed, and dont show next results.

The code is:

var storeComboProductosCodigo = new Ext.data.JsonStore({
url: 'globals/ajaxComboData.class.php',
method:'POST',
root: 'data',
totalProperty: 'total',
id: 'idProducto',
fields: ['idProducto','nombre','comentarios','familia','codigo'],
});

var resultTpl = new Ext.XTemplate(
'<tpl for="."><div class="search-item">',
'<span><b>NOMBRE: </b> {nombre}<br /><b>CODIGO: </b> {codigo}<br/><b>FAMILIA: </b> {familia}</span>',

'</div></tpl>'
);

var search = new Ext.form.ComboBox({
store: storeComboProductosCodigo,
displayField:'codigo',
typeAhead: false,
loadingText: 'Cargando...',
width: 570,
pageSize:10,
hideTrigger:true,
tpl: resultTpl,
itemSelector: 'div.search-item',
onSelect: function(record){ // override default onSelect to do redirect
alert(record.data.idProducto)
}
});

// THE SERVER CODE

<?php

include_once('db.class.php');
class ajaxComboData {

private $db;
private $req;
private $idCurso;
private $start;
private $limit;

function __construct() {

$this->db = new Database();
$this->req = $this->db->req();

$this->start = isset($_POST['start'])?$_POST['start']:0; //posición a iniciar
$this->limit = isset($_POST['limit'])?$_POST['limit']:10; //número de registros a mostrar

$this->getProds();


}





private function getProds(){

$query = "SELECT idProducto,
nombre,
comentarios,
familia,
codigo
FROM productos
WHERE codigo LIKE '". $_POST['query'] ."%'
LIMIT 20";
$rsProductos = $this->db->tquery($query);
$row_rsProductos = mysql_fetch_assoc($rsProductos);
$totalRows_rsProductos = mysql_num_rows($rsProductos);

$data=array();

if($totalRows_rsProductos>0){

do{

$data[]=array('idProducto'=>$row_rsProductos['idProducto'],'nombre'=>$row_rsProductos['nombre'],'comentarios'=>substr($row_rsProductos['comentarios'],0,100),
'familia'=>$row_rsProductos['familia'],'codigo'=>$row_rsProductos['codigo']);


}while($row_rsProductos = mysql_fetch_assoc($rsProductos));

}


echo json_encode(
array(
"success"=> true,
"total"=> $totalRows_rsProductos,
"data" => array_splice($data,$this->start,$this->limit)
)
);


}




}

$checkAjax = new ajaxComboData;
?>

Someone can help me????
Thanks