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

5 posts, 0 answers
  1. Spencer
    Spencer avatar
    2 posts
    Member since:
    Oct 2014

    Posted 07 May 2015 Link to this post

    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?

     

  2. Eyup
    Admin
    Eyup avatar
    3012 posts

    Posted 12 May 2015 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mike
    Mike avatar
    7 posts
    Member since:
    Sep 2015

    Posted 28 Jul Link to this post

    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?

  5. Eyup
    Admin
    Eyup avatar
    3012 posts

    Posted 02 Aug Link to this post

    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
  6. Mike
    Mike avatar
    7 posts
    Member since:
    Sep 2015

    Posted 02 Aug in reply to Eyup Link to this post

    I see now.

    Thanks for your response.

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017