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

4

2 回答 2

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> 

此模式可以在网格设计器中、直接在网格标记中甚至在运行时分配给 Pager.Pattern 属性。剩下的唯一事情是实现gotoPage()JavaScript 函数(标记,第 17 行),该函数将转到用户输入的页码。这里是:

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;  
    }  
} 
于 2012-03-07T11:40:42.933 回答
0

我相信这PageSize是自定义标签的数量,当您使用自定义分页时。为了给网格每页只提供三行,您必须在网格的 DataBinding 事件中只给它三行。

使用此网格的自定义分页不仅仅是寻呼机的自定义外观 - 它是关于您自己控制大部分分页过程。网格将显示您的自定义标签,并将它们全部变成超链接,除了指示为当前页面的那个。当您单击其中一个链接时,将引发 PageIndexChanged,它会告诉您单击的链接的索引。你用那个索引做什么取决于你。

于 2009-04-07T01:40:20.003 回答