We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Jump to a certain record

I am using v10.4.0.71 under vs2012.
 
I have a grid with a scroll bar.  The grid has about 100 rows and the height of the grid allows it to display about 10 rows.
 
I would like to be able to jump (on Not IsPostBack) to a record in the middle of the grid (let say the 25th records). 
 
The best way is to somehow do it with the primary key value.  If that is not possible I can translate the key value to a row number.
 
Thanks for any help in advance.

5 Replies

MK Maithiliy K Syncfusion Team January 16, 2013 11:28 AM UTC

Hi Randy Wang ,

Thanks for your interest in Syncfusion products.

Please have the below sample to achieve your requirement of “Jump to a certain record”.  We are selecting the row based on the value entered in the textbox and the scrollbar is scrolled automatically based on the selected row. Please refer the below code snippet for selecting the particular row.

Code snippet:

this.GridGroupingControl1.CurrentTable.Records[s].SetCurrent();

Sample link:  http://www.syncfusion.com/downloads/Support/DirectTrac/95417/simple sample grid web-368499202.zip


Please let us know if you have any concerns.

Regards,

Maithiliy K



RW Randy Wang January 21, 2013 11:03 PM UTC

I am still having problem with the jump.
 
I added a simple line in my form PreRender event and the grid does not jump.

    Me.GridGroupingControl2.CurrentTable.Records(30).SetCurrent()

The only different, I can see between the sample code and mine is that mine uses a SQL datasource and the sample does not.  Mine is done in PreRender and the sample is in Load (which I cannot do).

Unfortunately I cannot run the sample code or any code downloaded from the site because the projects reference controls with version 10.404.0.53 while my install version is 10.404.0.71.  I tried to replace the assembly in web.config but that didn't work either.

I was provided a javascript by support and that seems to work but I think the SetCurrent solution is better.  I would rather used that than sending javascript to the client to set the position.  The javascript is:

<script type='text/javascript'>

$(document).ready(function () {

$(__TableScrollerCollection.scrollers[0].vscrollDiv).scrollTop    (__gridTable.tableElement.rows[row#].offsetTop);

});

</script>

 



BM Bala Murugan A.S Syncfusion Team January 23, 2013 12:07 PM UTC

Hi Randy Wang,

Thanks for your update.

We suggest you to set ReCreateChildControls property as true in order to resolve your reported issue. Please refer the below code snippet.

[C#]

protected void Page_PreRender(object sender, EventArgs e)

    {

      

        if (!string.IsNullOrEmpty(txtbox.Text))

        {

            if ((Convert.ToInt16(txtbox.Text) > 30))

                MessageBox.Show("Enter the row index value with 30");

            else

            {

                s = Convert.ToInt16(txtbox.Text);

                this.GridGroupingControl1.CurrentTable.Records[s].SetCurrent();

            }

        }

        this.GridGroupingControl1.ReCreateChildControls = true;

      

    }

Please try the above code and let me know if you have any concerns.

Regards,

Bala Murugan A.S



RW Randy Wang January 23, 2013 09:19 PM UTC

Adding RecreateChildControls did not work.  The code is boiled down to very simple steps.  In page load I did this which loads 100 records to the grid.
Me.GridGroupingControl2.DataSource = GenerateDataSource()
Me.GridGroupingControl2.DataBind()
In PreRender I have these two lines to position the records.  That is it for code behind.
Me.GridGroupingControl2.CurrentTable.Records(30).SetCurrent()Me.GridGroupingControl2.ReCreateChildControls = True
And this is the rest of the control definition in aspx.
 
<Syncfusion:GridGroupingControl ID="GridGroupingControl2" runat="server"
DataMember="DefaultView" DataSourceCachingMode="ViewState" BorderCollapse="Separate" ShowGroupDropArea="False"  AutoSaveChildControlChanges="True" ClientObjectID="__essentialGrid" FrozenRows="1" Height="600px" JsonActionMapper="JsonAction" PageSize="0"
ReCreateChildControls="True" SaveEmpty="True" ClientSideColumnResizing="False"
DragSelectionBackColor="Yellow" GroupDropAreaText="Drag columns here" ShowWaitingPopupOnPostBack="True" EnableCallbacks="False" >
<TableOptions AllowSortColumns="True" ShowRowHeader="false" ShowTableRowHeaderAsCoveredRange="False"
AllowDragColumns="False" ListBoxSelectionMode="none" RecordMouseHoverColor='Gray' />
          

<TableDescriptor AllowNew="false" AllowEdit="false" TopLevelGroupOptions-ShowCaption="false">

<Columns>
<syncfusion:GridColumnDescriptor HeaderText="Customer ID" MappingName="CustomerID" Width="100">
<Appearance>
<AnyRecordFieldCell CssClass="EG_RowCell" HorizontalAlignment="Center" />
<AlternateRecordFieldCell CssClass="EG_AlternateRowCell" HorizontalAlignment="Center" />
</Appearance>
</syncfusion:GridColumnDescriptor>
<syncfusion:GridColumnDescriptor HeaderText="Customer Name" MappingName="CustomerName" Width="100">
</syncfusion:GridColumnDescriptor>

<syncfusion:GridColumnDescriptor HeaderText="Contact Name" MappingName="ContactName" Width="100"></syncfusion:GridColumnDescriptor>

</Columns>
</TableDescriptor>
<Appearance>
<ColumnHeaderCell HorizontalAlignment="Center" VerticalAlignment="Bottom" CssClass="EG_HeaderCell" ShowButtons="Hide"/>
<AnyRecordFieldCell CssClass="EG_RowCell" TextMargins-Left="10" TextMargins-Top="5" TextMargins-Right="10" />
<AlternateRecordFieldCell CssClass="EG_AlternateRowCell" TextMargins-Left="10" TextMargins-Top="5" TextMargins-Right="10"/>
</Appearance>

</syncfusion:GridGroupingControl>



BM Bala Murugan A.S Syncfusion Team January 24, 2013 12:10 PM UTC

Hi Randy Wang,

Thanks for your update.

We regret for the inconvenience caused. We are unable to reproduce your reported issue in our end. We have prepared a simple sample to demonstrate this and the same can be downloaded from the below link.

Sample: JumpToRecord.zip

Please try the above sample and if still issue exist, could you please try to reproduce your issue in the above sample and send back to us.

Please let us know if you have any concerns.

Regards,

Bala Murugan A.S


Loader.
Live Chat Icon For mobile
Up arrow icon