This is a migrated thread and some comments may be shown as answers.

Selected a page from RadDataForm from a field value instead of with CurrentPageIndex

4 Answers 224 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Spencer
Top achievements
Rank 1
Spencer asked on 07 May 2015, 07:44 PM

I am wanting to programmatically select a page (item?) from the DataForm during page_load from a querystring.

 

I am using a RadListView for selecting an item and displaying/passing the RadListView's selection to the DataForm by making use of the ListView's DataItemIndex.

 It seems to work as both controls are bound to the same datasource. (I was worried that perhaps the ordering and indexes would not match up between the two controls, but so far it seems to be fine).

It looks something like this:

protected void RequestsListView_ItemCommand(object sender, RadListViewCommandEventArgs e)
        {
            if (e.CommandName == "ItemSelect")
            {
                SelectedRequestDataForm.CurrentPageIndex = ((RadListViewDataItem)e.ListViewItem).DataItemIndex; 
            }
        }

 

So my question is how do I basically do the same thing but instead of using DataItemIndex / CurrentPageIndex... how can I just use actual field values to match and select on? Can I set the selected page of the DataForm by matching a value of a particular page's DataKey (or any field)? 

 

I have looked through the API reference to see if there was anything besides CurrentPageIndex that I could use, but I haven't found one. One idea I've had is to just loop through all pages and on each page attempt to match a DataItem's value... then use CurrentPageIndex to get the value. But, there doesn't seem to be a collection that corresponds to all the pages associated to the DataForm. Oddly enough, there is a PageCount property though!

 

What might I do? Does DataPager already accomplish all this and I just don't realize it?

 

4 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 12 May 2015, 08:33 AM
Hi Spencer,

This requirement may be somewhat tricky. You will need to find a way to determine the page and the position of the given record from the query string. Using the unique DataKeyValue of the item you can access the database position of the record by initiating some server-side query operation depending on your datasource type. Then, you can make some calculations to determine on which page the record is located on and go to that page using the CurrentPageIndex property. For instance, if you are using SQL, you can use an approach similar to the demonstrated implementation in the attached web site.

Hope this helps.

Regards,
Eyup
Telerik
0
Mike
Top achievements
Rank 1
answered on 28 Jul 2016, 08:21 PM

I have a similar question.

 

I'm loading data using model binding by setting the itemType and SelectMethod on my RadDataForm control. I'm loading 500 records. When I place the RadDataForm into Edit mode, it positions to page index 0, or the record with ID = 2. 

How can I search the RadDataForm control for specific IDs and determine the page index? Why is there no page collection I can search.

Put another way how can I enumerate pag es to find what ID I'm looking for?

0
Eyup
Telerik team
answered on 02 Aug 2016, 02:35 PM
Hello Michael,

The RadDataForm loads only a single item at a time, similar to a RadListView with page size set to 1:
http://demos.telerik.com/aspnet-ajax/listview/examples/paging/pagingwithraddatapager/defaultcs.aspx

Even with RadGrid, you can traverse only the visible items on the current page - there is no access to other records on other pages. Otherwise, all records would be loaded and rendered all the time, which would be a killer.

Therefore, you will need to determine this information on database level, as explained in my initial post.

Regards,
Eyup
Telerik by Progress
0
Mike
Top achievements
Rank 1
answered on 02 Aug 2016, 03:56 PM

I see now.

Thanks for your response.

Tags
DataForm
Asked by
Spencer
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Mike
Top achievements
Rank 1
Share this question
or