Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_Related Related Topics sp_TopicIcon
Paging Help Desperately
Tags: paging
27/05/2010
09:53
Avatar
amithasija
Member
Members
Forum Posts: 9
Member Since:
27/05/2010
sp_UserOfflineSmall Offline

Hi,

I m getting issues in paging, i has 202 rows but showing pag1 of 1 with 10 records at time.please suggest.

My Code

var actionHandlerGrid = “admin/contact/grid”;

jQuery(”#multiple37″).jqGrid({
url:actionHandlerGrid,
datatype: “json”,
height: 255, width: 860,
colNames:['Index','Name', 'Code'],
colModel:[
{name:'id',index:'id', width:65, sorttype:'int'},
{name:'country_name',index:'country_name', width:150},
{name:'area',index:'area', width:100} ],
rowNum:10,
rowTotal: 20,
rowList : [10,30,50],
loadonce:true,
mtype: “GET”,
rownumbers: true,
rownumWidth: 40,
gridview: true,
pager: ‘#pmultiple37′,
sortname: ‘id’,
viewrecords: true,
sortorder: “asc”,
caption: “Multiple search on local Data” });

jQuery(”#multiple37″).jqGrid(’navGrid’,'#pmultiple37′,{del:false,add:false,edit:false},{},{},{},{});

Php Code File Return

{"page":"1","total":21,"records":202,"rows":[{"id":"9","cell":["9","Albania","Europe"]}.....

}]}

regards

amit

27/05/2010
14:40
Avatar
amithasija
Member
Members
Forum Posts: 9
Member Since:
27/05/2010
sp_UserOfflineSmall Offline

Done 🙂

Hope it will help somebody.

Javascript Code

var actionHandlerGrid = "<?php echo WEBSITE_URL ?>admin/contact/grid";

    

jQuery("#single").jqGrid({
    scrollrows : true,
       url:actionHandlerGrid,
    datatype: "json",
    height: 255, width: 860,
       colNames:['Id','Country Name', 'Area'],
       colModel:[
           {name:'id',index:'id', width:65, sorttype:'int'},
                {name:'country_name',index:'country_name', width:150},
                {name:'area',index:'area', width:100} ],
       rowNum:10,
       rowList:[10,20,30],
       pager: '#psingle',
       sortname: 'country_name',
    viewrecords: true,
    sortorder: "desc",
    caption:"Navigator Example",
    height:150
});
jQuery("#single").jqGrid('navGrid','#psingle',
{del:false,add:false,edit:false}, //options
{height:280,reloadAfterSubmit:false}, // edit options
{}, // add options
{reloadAfterSubmit:false}, // del options
{} // search options
);

Php Code

function gridAction() {

    
    $page = $this->getRequest()->getParam('page');
    $limit = $this->getRequest()->getParam('rows');
    $sidx = $this->getRequest()->getParam('sidx');
    $sord = $this->getRequest()->getParam('sord');
    $totalrowsData = $this->getRequest()->getParam('totalrows');

    if(!$sidx){ $sidx =1; }
    $totalrows = isset($totalrowsData) ? $totalrowsData: false;
    if($totalrows) {
        $limit = $totalrows;
    }

    $objCountry = new Country();
    $count = $objCountry->fetchMyCount();

    if( $count >0 ) {
        $total_pages = ceil($count/$limit);
    } else {
        $total_pages = 0;
    }

    if ($page > $total_pages) $page=$total_pages;
    if ($limit<0) $limit = 0;
    $start = $limit*$page - $limit; // do not put
    if ($start<0) $start = 0;

    
        
    $countries_data =  $objCountry->getRequiredData($start, $limit);

    //$countries_data = $objCountry->fetchAll($objCountry->select()->limit($start, $limit));

    $responce->page = $page; $responce->total = $total_pages; $responce->records = $count;
    $i=0;

    foreach($countries_data as $data) {

        $responce->rows[$i]['id']=$data['id'];
            $responce->rows[$i]['cell']=array($data['id'],$data['country_name'],$data['area']);
        $i++;
    }
    
    echo json_encode($responce); die;

}

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
54 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information