Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery EasyUI DataGrid - Displaying Massive Data with a Virtual Scroll View

jQuery EasyUI DataGrid - Displaying Massive Data with a Virtual Scroll View

The datagrid's virtual scrolling feature can be used to display a large number of records without pagination. When scrolling the vertical scrollbar, the datagrid performs ajax requests to load and refresh the existing records. The entire refresh process is smooth without flickering. In this tutorial, we will create a datagrid and use the virtual scrolling feature to load data from the server.

Create the DataGrid

To apply the virtual scrolling feature to the datagrid, the 'view' property should be set to 'scrollview'. Users should download scrollview from the datagrid extensions and reference the scrollview file in the head of the page.









    

        

            

            

            

            

            

            

            

        

    
Inv NoDateNameAmountPriceCostNote

Note that here we do not need to use the pagination property, but the pageSize property is required so that when performing ajax requests, the datagrid fetches the specified number of records from the server.

Server-side code

datagrid27_getdata.php



$page = isset($_POST['page']) ? intval($_POST['page']) : 1;

$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 50;



$items = array();

date_default_timezone_set('UTC');

for($i=1; $i<=$rows; $i++){

    $index = $i+($page-1)*$rows;

    $amount = rand(50,100);

    $price = rand(10000,20000)/100;

    $items[] = array(

        'inv' => sprintf("INV%04d",$index),

        'date' => date('Y-m-d',time()+24*3600*$i),

        'name' => 'Name' . $index,

        'note' => 'Note' . $index,

        'amount' => $amount,

        'price' => sprintf('%01.2f',$price),

        'cost' => sprintf('%01.2f',$amount*$price)

    );

}

$result = array();

$result['total'] = 8000;

$result['rows'] = $items;

echo json_encode($result);

Download the jQuery EasyUI example

jeasyui-datagrid-datagrid27.zip