This is a migrated thread and some comments may be shown as answers.
RadGrid problems with data
5 Answers 60 Views
This is a migrated thread and some comments may be shown as answers.
Jose
Top achievements
Rank 2
Jose asked on 10 Jan 2011, 11:07 AM
Hi,

I'm having some problems with records disappearing from grid.
I'm attaching screenshots to show the problem.

This is the behavior of the problem:

Web page is loaded and all records are retrieve (164 records) paged every 10 records (very fast, 3 sec).
Moving to another page of records all works fine but very slow (22 sec).
If I try to filter the grid from the filter field, for a record in the list, the record is not found (confirmed, the record exists).
If I clear the filter (setting button to None) it takes a lot of time to get all record again and only 131 records are showed.
I've confirmed that the bind function always return 164 records and not 131 as grid show.

This is the code for aspx page:

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="List.aspx.cs" Inherits="Quasar.WebUI.Customers.Customers.List" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <title>Quasar | CRM - Customers List</title>
</asp:Content>
 
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
 
   <telerik:RadAjaxLoadingPanel ID="ListRadAjaxLoadingPanel" runat="server" Skin="Default" />
 
   <telerik:RadAjaxManager ID="ListRadAjaxManager" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="ListGrid">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="ListGrid" LoadingPanelID="ListRadAjaxLoadingPanel" UpdatePanelHeight="" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
 
    <telerik:RadWindowManager ID="ListRadWindowManager" runat="server" />
 
    <div class="findField">
        <asp:Label ID="FindFieldLabel" runat="server" AssociatedControlID="FindFieldTextBox">Customer :</asp:Label>
        <telerik:RadTextBox ID="FindFieldTextBox" runat="server" EmptyMessage="(empty)" MaxLength="50" Columns="50"
            SelectionOnFocus="SelectAll" ToolTip="Find Customer"></telerik:RadTextBox>
        <telerik:RadButton ID="FindButton" runat="server" Icon-PrimaryIconUrl="~/Images/Find.png" Text="Find" Width="75px"
            onclick="FindButton_Click">
        </telerik:RadButton>
    </div>
 
    <telerik:RadGrid ID="ListGrid" runat="server" AllowFilteringByColumn="True"
        AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"
        GridLines="None" ShowStatusBar="True" ShowGroupPanel="True" EnableLinqExpressions="false"
        onneeddatasource="ListGrid_NeedDataSource"
        onitemcommand="ListGrid_ItemCommand">
 
        <ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True" AllowDragToGroup="True">
            <Selecting AllowRowSelect="False" />
        </ClientSettings>
 
        <GroupingSettings CaseSensitive="false" />
 
        <MasterTableView DataKeyNames="CustomerId" CommandItemDisplay="Top">
            <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
 
            <RowIndicatorColumn>
                <HeaderStyle Width="20px"></HeaderStyle>
            </RowIndicatorColumn>
 
            <ExpandCollapseColumn>
                <HeaderStyle Width="20px"></HeaderStyle>
            </ExpandCollapseColumn>
 
            <NestedViewSettings>
                <ParentTableRelation>
                    <telerik:GridRelationFields DetailKeyField="ContactId" MasterKeyField="CustomerId" />
                    <telerik:GridRelationFields DetailKeyField="AddressId" MasterKeyField="CustomerId" />
                </ParentTableRelation>
            </NestedViewSettings>
 
            <NestedViewTemplate>
 
                <asp:Panel runat="server" ID="InnerContainer" CssClass="viewWrap">
                    <telerik:RadTabStrip runat="server" ID="CustomersTabStrip" MultiPageID="CustomersMultipage" SelectedIndex="0">
                        <Tabs>
                            <telerik:RadTab runat="server" Text="Contacts" PageViewID="ContactsPageView">
                            </telerik:RadTab>
                            <telerik:RadTab runat="server" Text="Addresses" PageViewID="AddressesPageView">
                            </telerik:RadTab>
                        </Tabs>
                    </telerik:RadTabStrip>
 
                    <telerik:RadMultiPage runat="server" ID="CustomersMultipage" SelectedIndex="0" RenderSelectedPageOnly="false">
 
                        <telerik:RadPageView runat="server" ID="ContactsPageView">
 
                            <telerik:RadGrid ID="ContactsGrid" runat="server" AllowSorting="false" AllowFilteringByColumn="false"
                                PageSize="5" AllowPaging="true" AutoGenerateColumns="False" GridLines="None"
                                onneeddatasource="ContactsGrid_NeedDataSource">
 
                                <ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True"
                                    AllowDragToGroup="True">
                                    <Selecting AllowRowSelect="True" />
                                </ClientSettings>
 
                                <MasterTableView DataKeyNames="ContactId">
 
                                    <Columns>
                                        <telerik:GridBoundColumn DataField="ContactId" HeaderText="Id"
                                            UniqueName="ContactId" Visible="false">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn HeaderText="Full Name" DataField="FullName" UniqueName="FullName">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn HeaderText="Position" DataField="Position" UniqueName="Position">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn HeaderText="Contact Type" DataField="ContactType.Description" UniqueName="ContactType">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridHyperLinkColumn DataNavigateUrlFields="Email" DataNavigateUrlFormatString="mailto:{0}"
                                            DataTextField="Email" HeaderText="Email" UniqueName="Email" Groupable="false"
                                            AllowFiltering="false">
                                        </telerik:GridHyperLinkColumn>
                                        <telerik:GridBoundColumn HeaderText="Phone" DataField="Phone" UniqueName="Phone">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn HeaderText="Mobile" DataField="Mobile" UniqueName="Mobile">
                                        </telerik:GridBoundColumn>
                                    </Columns>
 
                                </MasterTableView>
 
                            </telerik:RadGrid>
 
                        </telerik:RadPageView>
 
                        <telerik:RadPageView runat="server" ID="AddressesPageView">
 
                            <telerik:RadGrid ID="AddressesGrid" runat="server" AllowSorting="false" AllowFilteringByColumn="false"
                                PageSize="5" AllowPaging="true" AutoGenerateColumns="False" GridLines="None"
                                onneeddatasource="AddressesGrid_NeedDataSource">
 
                                <ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True"
                                    AllowDragToGroup="True">
                                    <Selecting AllowRowSelect="True" />
                                </ClientSettings>
 
                                <MasterTableView DataKeyNames="AddressId">
 
                                    <Columns>
                                        <telerik:GridBoundColumn DataField="AddressId" HeaderText="Id"
                                            UniqueName="AddressId" Visible="false">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn HeaderText="Address Type" DataField="AddressType" UniqueName="AddressType">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn HeaderText="Full Address" DataField="FullAddress" UniqueName="FullAddress">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn HeaderText="Zip Code" DataField="ZipCode" UniqueName="ZipCode">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn HeaderText="City" DataField="City" UniqueName="City">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn HeaderText="Province" DataField="Province" UniqueName="Province">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn HeaderText="Country" DataField="Country" UniqueName="Country">
                                        </telerik:GridBoundColumn>
                                    </Columns>
 
                                </MasterTableView>
 
                            </telerik:RadGrid>
 
                        </telerik:RadPageView>
 
                    </telerik:RadMultiPage>
 
                </asp:Panel>
 
            </NestedViewTemplate>
 
            <Columns>
                <telerik:GridButtonColumn ButtonType="ImageButton" Reorderable="False"
                    Resizable="False" ShowFilterIcon="False" ShowSortIcon="False"
                    UniqueName="EditButton" ImageUrl="~/Images/Edit.png" CommandName="Edit">
                    <ItemStyle Width="20px" HorizontalAlign="Center" VerticalAlign="Middle" />
                </telerik:GridButtonColumn>
                <telerik:GridImageColumn AllowFiltering="False" AllowSorting="False"
                    DataAlternateTextField="Name" DataImageUrlFields="Logo"
                    DataImageUrlFormatString="~/Images/Customers/{0}" Groupable="False"
                    HeaderText="Logo" ImageHeight="64px" ImageWidth="64px" ShowSortIcon="False"
                    UniqueName="Logo" ItemStyle-Width="75px">
                    <ItemStyle Width="75px" />
                </telerik:GridImageColumn>
                <telerik:GridBoundColumn DataField="CustomerId" HeaderText="Id" UniqueName="CustomerId" Visible="false"
                    AllowFiltering="False">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Name" HeaderText="Name" UniqueName="Name" AutoPostBackOnFilter="true"
                    CurrentFilterFunction="Contains">
                </telerik:GridBoundColumn>
                <telerik:GridHyperLinkColumn DataNavigateUrlFields="Web" DataNavigateUrlFormatString="{0}" DataTextField="Web"
                    HeaderText="Web" UniqueName="Web" Target="_blank" Groupable="false" AllowFiltering="false">
                </telerik:GridHyperLinkColumn>
                <telerik:GridBoundColumn DataField="Group.Name" HeaderText="Group" UniqueName="Group" AutoPostBackOnFilter="true"
                    CurrentFilterFunction="Contains">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="AccountManager.FullName" HeaderText="Acct. Manager"
                    UniqueName="AccountManager" AutoPostBackOnFilter="true"
                    CurrentFilterFunction="Contains">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="SIC.Description" HeaderText="SIC"
                    UniqueName="SIC" AutoPostBackOnFilter="true"
                    CurrentFilterFunction="Contains">
                </telerik:GridBoundColumn>
                <telerik:GridCheckBoxColumn DataField="IsProspect" HeaderText="Prospect"
                    UniqueName="IsProspect" AutoPostBackOnFilter="true" CurrentFilterFunction="EqualTo">
                </telerik:GridCheckBoxColumn>
                <telerik:GridButtonColumn ButtonType="ImageButton" Reorderable="False"
                    Resizable="False" ShowFilterIcon="False" ShowSortIcon="False"
                    UniqueName="DeleteButton" ImageUrl="~/Images/Delete.png" CommandName="Delete"
                    ConfirmDialogType="RadWindow" ConfirmText="Are you sure you want to delete this record?" ConfirmTitle="Delete record..."
                    ConfirmDialogHeight="130px">
                    <ItemStyle Width="20px" HorizontalAlign="Center" VerticalAlign="Middle" />
                </telerik:GridButtonColumn>
            </Columns>
 
        </MasterTableView>
 
        <PagerStyle Mode="NextPrevAndNumeric" Position="Bottom" />
 
        <HeaderContextMenu EnableImageSprites="True" CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu>
 
    </telerik:RadGrid>
 
</asp:Content>

Code  Behind for binding:

#region Binding
 
// Bind main grid
protected void ListGrid_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
    ListGrid.DataSource = BindControls();
}
 
protected IEnumerable<Customer> BindControls()
{
    var customers = customersRepository.GetAllCustomers();
 
    return customers;
}
 
// Bind contacts grid
protected void ContactsGrid_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
    (sender as RadGrid).DataSource = BindContactsControls();
}
 
protected IEnumerable<Contact> BindContactsControls()
{
    var contacts = contactsRepository.GetContactsByCustomer(System.Convert.ToInt32(CurrentRecordId));
 
    return contacts;
}
 
// Bind addresses grid
protected void AddressesGrid_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
    (sender as RadGrid).DataSource = BindAddressesControls();
}
 
protected IEnumerable<Address> BindAddressesControls()
{
    var addresses = addressesRepository.GetAddressesByCustomer(System.Convert.ToInt32(CurrentRecordId));
 
    return addresses;
}
 
#endregion

And this is the code for Customers repository:

using System.Linq;
 
using System.Transactions;
using System.Data;
 
namespace Quasar.Repository
{
    public class CustomersRepository
    {
        // Create data context
        private QuasarEntities entities = new QuasarEntities();
 
        // Retrieve all Customers
        public IQueryable<Customer> GetAllCustomers()
        {
            return entities.Customers.OrderBy(o => o.Name);
        }
 
        // Retrieve a Customer by Id
        public Customer GetCustomer(int id)
        {
            return entities.Customers.FirstOrDefault(d => d.CustomerId == id);
        }
 
        // Add Customer
        public int Add(Customer customer)
        {
            using (TransactionScope transaction = new TransactionScope())
            {
                try
                {
                    entities.Customers.AddObject(customer);
                    entities.SaveChanges();
 
                    // Commit Transaction
                    transaction.Complete();
 
                    return customer.CustomerId;
                }
                catch
                {
                    return 0;
                }
            }
        }
 
        // Delete Customer
        public bool Delete(Customer customer)
        {
            using (TransactionScope transaction = new TransactionScope())
            {
                try
                {
                    // Delete Customer and childs
                    entities.Customers.DeleteObject(customer);
                    entities.SaveChanges();
 
                    // Commit Transaction
                    transaction.Complete();
 
                    return true;
                }
                catch
                {
                    return false;
                }
            }
        }
 
        // Persistence
        public bool Save()
        {
            using (TransactionScope transaction = new TransactionScope())
            {
                try
                {
                    entities.SaveChanges();
 
                    // Commit Transaction
                    transaction.Complete();
 
                    return true;
                }
                catch
                {
                    return false;
                }
            }
        }
    }
}


Please, any help?

Regards
Jose

5 Answers, 1 is accepted

Sort by
0
Jose
Top achievements
Rank 2
answered on 11 Jan 2011, 08:48 AM
Please, any idea regarding this behavior?
Thanks
0
Mira
Telerik team
answered on 13 Jan 2011, 05:05 PM
Hello Jose,

Please take a look at the following resources to see how searching on button click can be implemented:
Search on key press/button click help topic
Web Mail Grid

In order to improve the performance with the nested view template, I recommend that you use the approach from the Hierarchy with Templates demo - wrap the content of the nested view in a panel and switch its visibility on expand/collapse.

Please give these suggestions a try and let me know how it goes.

All the best,
Mira
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Jose
Top achievements
Rank 2
answered on 13 Jan 2011, 09:07 PM
Hi,

I'm not sure if my problem has been correctly understand.
The problem that I'm having is the rad grid is loosing records. The filter is working but when I type some text in the filter textbox and press enter or filter button, some records are found but another records aren't found (they are retrieved in binding function). Also after a filter operation, when I clear the filter with the "none" option in the filter menu, not all records are filled in the grid and i don't know why. The binding function are retrieving all records from the database correctly but the grid is not showing its.

You can see this behavior in the screenshots attached in the previous post. The first screenshot is before filter and the second screenshot is after a filter operation and clear filter is done.

I'm working with the latest version of telerik grid (2010.3 1215) and the standard jquery version from Visual Studio.
Could be a problem with jquery scripts? I was reading in the version notes that this version of grid works with a jquery version 1.4.4  but in my project I'm using 1.4.1 version of jquery (standard for Visual Studio projects).

If this is the problem, how can I update the version of jquery in my project?

Regards
Jose
0
Jose
Top achievements
Rank 2
answered on 14 Jan 2011, 10:12 AM
Hi,

More information regarding the issue.
If I remove this code from columns, filters works fine and there aren't missing records:

AutoPostBackOnFilter="true"CurrentFilterFunction="Contains"

Any idea?
Regards
Jose
0
Mira
Telerik team
answered on 18 Jan 2011, 12:00 PM
Hello Jose,

Based on the supplied information, it is hard to determine what is causing the issue.
Please open a formal support ticket and send us a small working project, demonstrating your full setup and showing the unwanted behavior.
We will debug it locally and get back to you.

Thank you in advance for the cooperation.

Best wishes,
Mira
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
Jose
Top achievements
Rank 2
Answers by
Jose
Top achievements
Rank 2
Mira
Telerik team
Share this question
or