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

Rad Grid not go previous page when last record of last page is being removed it shows a message "No records to display".

1 Answer 158 Views
Grid
This is a migrated thread and some comments may be shown as answers.
kd
Top achievements
Rank 1
kd asked on 24 Mar 2012, 01:37 PM
Hi all,
I have bid a radgrid with entity data source object control and i was performing all operations like insert,edit, delete, filter, sorting, paging so all of these working fine but when i am jumping or navigate on last page and delete whole records of last page when last record is deleted than grid show message "No records to display." rather than navigate previous page so can any one please tell me how can i acheive this

Thanks,

1 Answer, 1 is accepted

Sort by
0
Accepted
Richard
Top achievements
Rank 1
answered on 26 Mar 2012, 09:19 PM
kd:

I was able to reproduce your exact behavior using the online demo: Grid/Entity Framework Operations. If you navigate to the last page and then delete all of the rows, one by one, the page will enventually say "No records to display" and it does not automatically move back to the previous page.

You could try this javascript as a work-around:

<script runat="server">
 
    protected void RadGrid1_ItemDeleted(object source, GridDeletedEventArgs e)
    {
        if ((e.Item.OwnerTableView.Items.Count - 1) == 0)
        {
            RadGrid1.CurrentPageIndex = 0;
        }
    }
</script>

And you can wire it up using onitemdeleted="RadGrid1_ItemDeleted"

<telerik:RadGrid Skin="Vista" AutoGenerateDeleteColumn="true" AutoGenerateEditColumn="true"
    GroupingEnabled="true" ShowGroupPanel="true" runat="server" DataSourceID="LinqDataSource1"
    AllowAutomaticDeletes="true" AllowAutomaticInserts="true" AllowAutomaticUpdates="true"
    AllowPaging="true" PageSize="12" AllowSorting="true" AllowFilteringByColumn="true"
    ID="RadGrid1" onitemdeleted="RadGrid1_ItemDeleted">
    <MasterTableView DataKeyNames="Id" CommandItemDisplay="Top">               
    </MasterTableView>
    <ClientSettings AllowColumnsReorder="true" AllowDragToGroup="true">
    </ClientSettings>

 Let me know if this helps!
Tags
Grid
Asked by
kd
Top achievements
Rank 1
Answers by
Richard
Top achievements
Rank 1
Share this question
or