0

I am using Infragistics UltraWebGrid in my application when I use custom paging I am not able to retrieve the specified number of records per page

The code I have written is string[] cusLabel;

in the grid initialise

grid.DisplayLayout.Pager.AllowCustomPaging = true;
grid.DisplayLayout.Pager.AllowPaging = true;        
grid.DisplayLayout.Pager.StyleMode = PagerStyleMode.CustomLabels;
grdSysManager.DisplayLayout.Pager.PageSize = 3;
getCustomLabel();
grdSysManager.DisplayLayout.Pager.CustomLabels = cusLabel;


private void getCustomLabel()
{
    DataTable dt = (DataTable)grdSysManager.DataSource;
    DataSet ds = new DataSet();
    ds = dt.DataSet;
    //ds = (DataSet)grdSysManager.DataSource;
    int NoOfRows = ds.Tables[0].Rows.Count;
    int PageSize = grdSysManager.DisplayLayout.Pager.PageSize;
    if (NoOfRows % PageSize == 0)
    {
        totalNoOfPagings = NoOfRows / PageSize;
    }
    else
    {
        totalNoOfPagings = (NoOfRows / PageSize) + 1;
    }

    cusLabel = new string[totalNoOfPagings + 2];

    cusLabel[0] = "First";

    for (int i = 1; i <= totalNoOfPagings; i++)
    {
        cusLabel[i] = i.ToString();
    }


    cusLabel[totalNoOfPagings + 1] = "Last";
}

Above is the code I written but it is displaying all the records from the table instead of 3 records per page. Am I missing anything?

Thanks

Danko Valkov
  • 1,038
  • 8
  • 17

2 Answers2

1
<table cellspacing='0' cellpadding='0' width='100%'>  
   <tr>  
       <td width='12%' align='left'>  
           [currentpageindex]/[pagecount]  
      </td>  
       <td width='76%'>  
           <b>[page:1:First]&nbsp;[prev]</b>  
           &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
           [default]  
           &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
           <b>[next]&nbsp;[page:[pagecount]:Last]</b>  
       </td>  

       <td width='12%' align='right' title='Enter page number and press Enter'>  
           Go to:  
           <input id='xtxtGotoPage' size='5' 
           style='font-family:verdana;font-size:8pt;padding:0 0 0 0' 
           type='text' onKeyPress='return gotoPage()' autocomplete='off' />  
      </td>  
   </tr>  
</table> 

This pattern can be assigned in grid designer, directly in grid markup or even at runtime to Pager.Pattern property. The only thing left is to implement gotoPage() JavaScript function (markup, Line 17) that would go to the page number that user enters. And here it is:

function gotoPage() {  

    if (event.keyCode == 13) {  

        var otxtGotoPage = event.srcElement;  
        var iPageNo = otxtGotoPage.value  

        if (!isNaN(iPageNo)) {  

            var oGrid = igtbl_getGridById('xuwgMyGrid');  

            if (iPageNo < 1 || iPageNo > oGrid.PageCount) {  
                alert('Please enter page number between 1 and ' +  
                        oGrid.PageCount)  
            } else {  
                oGrid.goToPage(iPageNo)  
            }     

        } else {  

            alert('Please enter correct numeric page number');  

        }  

        otxtGotoPage.focus();  
        otxtGotoPage.value = '';  
        return false;  
    }  
} 
kapex
  • 28,903
  • 6
  • 107
  • 121
vaidehi
  • 11
  • 1
0

I believe that PageSize is the number of custom labels, when you're using custom paging. In order to give the grid only three rows per page, you have to give it only three rows in the grid's DataBinding event.

Custom paging with this grid isn't just about the custom appearance of the pager - it's about you taking control of most of the paging process yourself. The grid will display your custom labels, and it will make them all into hyperlinks except for the one indicated as the current page. When you click one of the links, the PageIndexChanged will be raised, and it will tell you the index of the link that was clicked. What you do with that index is up to you.

John Saunders
  • 160,644
  • 26
  • 247
  • 397