Skip to content

Infragistics Community Forum / Cross Platform / Ultimate UI for Xamarin / Set page index to start of the page when grid data has changed

Set page index to start of the page when grid data has changed

New Discussion
Manju
Manju asked on Jun 19, 2012 8:04 AM

 

Version: Ultrawebgrid11.1

I have a grid whose DataSource is set in IntializeDataSource. I also have multiple dropdowns on the page based on I fetch data from database and set the datasource.

Paging and other grid properties are initialized inside IntializeDataSource itself.

 

Consider grid has 20 pages of data.

1. Navigate to 20th page. 

2. Change the dropdown value.

(code fetches a set of data based on dropdown value and is given to grid's DataSource)

3. Now Grid has only 15 pages of data. But page is still indexed at 20th page which has no data.

(to view the data I have to navigate to first page)

 

How to make page index set to first page when data in the grid is changed? And also when i filter the grid page will not come back to first page.

 

 

Code:

Protected Sub SampleGrid_InitializeDataSource(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.UltraGridEventArgs) Handles 
SampleGrid .InitializeDataSource

 

 

Dim htmlString As New StringBuilder

 

' Properties needed to enable LoadOnDemand

SampleGrid.Browser = BrowserLevel.Xml

SampleGrid.DisplayLayout.LoadOnDemand = LoadOnDemand.Xml

 

'LoadOnDemand configuration options

SampleGrid.DisplayLayout.RowsRange = 100

SampleGrid.DisplayLayout.XmlLoadOnDemandType = XmlLoadOnDemandType.Accumulative

 

SampleGrid.DisplayLayout.Pager.StyleMode = PagerStyleMode.QuickPages

SampleGrid.DisplayLayout.Pager.AllowCustomPaging = False

SampleGrid.DisplayLayout.Pager.AllowPaging = True

SampleGrid.DisplayLayout.Pager.PageSize = 100

SampleGrid.DisplayLayout.Pager.QuickPages = 5

 

htmlString.Append("<table cellspacing='0' cellpadding='0' style='width:100%;border:solid 1px Black;'>")

htmlString.Append("<tr>")

htmlString.Append("<td width='25%' align='right'>Viewing page [currentpageindex] of [pagecount] </td>")

htmlString.Append("<td align='center'>")

htmlString.Append("<b>[page:1:First]&nbsp;[prev]</b>")

htmlString.Append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;")

htmlString.Append("[default]")

htmlString.Append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;")

htmlString.Append("<b>[next]&nbsp;[page:[pagecount]:Last]</b>")

htmlString.Append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;")

htmlString.Append("</td>")

htmlString.Append("<td width='25%' align='left' title='Enter page number and press Enter'>")

htmlString.Append("Go to:<input id='PagerGotoPageNumber' size='5' style='vertical-align:text-bottom;height:20px;font-family:verdana;font-size:8pt;padding:0 0 0 0;border:solid 1px black' onkeydown='return gotoPageKeyDown();' type='text' autocomplete='off' />")

htmlString.Append("<button style='height:22px' onclick='gotoPage();'>Go</button>")

htmlString.Append("</td>")

htmlString.Append("</tr>")

htmlString.Append("</table>")

 

SampleGrid.DisplayLayout.Pager.Pattern = htmlString.ToString()

 

LoadGrid()

 

End Sub

Private dsData As System.Data.DataSet = Nothing

 

Public Sub LoadGrid()

 

 

Dim totalNumOfRecords As Integer = 0

 

dsData = Get Data from Database

totalNumOfRecords = dsData.Tables(0).Rows.Count

 

If totalNumOfRecords > Me.
SampleGrid .DisplayLayout.Pager.PageSize Then

Me.SampleGrid.DisplayLayout.Pager.PageCount = Math.Ceiling(totalNumOfRecords / Me.SampleGrid .DisplayLayout.Pager.PageSize)

End If

 

SampleGrid.DataSource = dsData.Tables(0)

 

End Sub

 

Protected Sub 
SampleGrid _InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.LayoutEventArgs) Handles 
SampleGrid .InitializeLayout

 

GatherFilterDataForColumnString(e.Layout.Bands(0).Columns.FromKey("xxx"))

GatherFilterDataForColumnDate(e.Layout.Bands(0).Columns.FromKey("yyy"))

 

End Sub

 

 

 

Sign In to post a reply

Replies

  • 0
    Hardik
    Hardik answered on Jun 13, 2012 7:36 AM

    I am also facing the same problem. The Grid does not restore the page index to first page on change of Datasource and when Filter is applied.

     

    • 0
      [Infragistics] Nikolay
      [Infragistics] Nikolay answered on Jun 15, 2012 1:01 PM

      Hello,

      I could suggest a possible solution – in the InitializeLayoutHandler and AfterFilterClosed client-side events, use this line of code to navigate to the first page:  igtbl_getGridById(gridName).goToPage(1);

      Let me know if this helps.

      • 0
        Manju
        Manju answered on Jun 19, 2012 7:55 AM

        Thank you Nikolay for the response.

        That really could be a possible solution.

        But I''ve managed to find a solution by moving all the Grid properties from InitializeDataSource to InitializeLayout and also by inserting the below condition in the InitializeLayoutHandler. 

        If Not SampleGrid.IsXmlHttpRequest Then

        SampleGrid.DisplayLayout.Pager.Reset()

        End If

      • 0
        [Infragistics] Nikolay
        [Infragistics] Nikolay answered on Jun 19, 2012 8:04 AM

        Hi msritmanju,

        Thank you for sharing your solution. 

        If you have any other questions, please feel free to contact me.

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Manju
Favorites
0
Replies
4
Created On
Jun 19, 2012
Last Post
14 years, 4 months ago

Suggested Discussions

Created by

Created on

Jun 19, 2012 8:04 AM

Last activity on

Jun 19, 2012 8:04 AM