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

InsertItem go to LastPage, I like it go to firstpage

4 Answers 134 Views
Grid
This is a migrated thread and some comments may be shown as answers.
binbin
Top achievements
Rank 1
binbin asked on 14 Oct 2008, 07:09 AM
As we know. when we click "add new record" on Grid

Then we will find and InterForm will be open. and the page is go to last page.(see Pageing and records)

but some times we need it go to first page. don't last page.
Becase we hope datasource order by id Descending.

Btw:I know how to set currentPage to fristpage after Insert

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 14 Oct 2008, 07:19 AM
Hi,

Try out the following code to show the insert form on the first page.
cs:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    {  
      if (e.CommandName == RadGrid.InitInsertCommandName)   
        {   
            e.Canceled = true;   
            e.Item.OwnerTableView.IsItemInserted = true;   
            e.Item.OwnerTableView.Rebind();   
            return;   
        }   
    } 

Thanks
Princy
0
Lucania
Top achievements
Rank 1
answered on 27 Apr 2012, 01:23 AM
Hi Princy,

I am experiencing this issue, and I have the following code in my ItemCommand:
case RadGrid.InitInsertCommandName:
    // cancel the default operation
    e.Canceled = true;
    //Prepare an IDictionary with the predefined values
    System.Collections.Specialized.ListDictionary newValues = new System.Collections.Specialized.ListDictionary();
    //set default checkbox value
    newValues["PlannerVisible"] = false;
    //Insert the item and rebind
    e.Item.OwnerTableView.InsertItem(newValues);
    break;
I have tried adding the e.Item.OwnerTableView.IsItemInserted = true; as suggested, but it makes no difference - the grid still goes to the last page. Is there something else I need to do? My grid is sorted in descending order like binbin.

Thanks

ROSCO
0
Princy
Top achievements
Rank 2
answered on 27 Apr 2012, 05:15 AM
Hell Ross,

Please try setting InsertItemPageIndexAction property in MasterTableView.
aspx:
<MasterTableView  InsertItemPageIndexAction="ShowItemOnCurrentPage">

Thanks,
Princy.
0
Lucania
Top achievements
Rank 1
answered on 27 Apr 2012, 06:07 AM
Thanks that works great!

ROSCO
Tags
Grid
Asked by
binbin
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Lucania
Top achievements
Rank 1
Share this question
or