Filtering not working

11 posts, 0 answers
  1. Simon
    Simon avatar
    75 posts
    Member since:
    Sep 2018

    Posted 07 Oct 2019 Link to this post

    Hello,

    I manually enter the text to be filtered in the textbox and click on the filter icon.

    However, the same records are still displayed.

    What is going wrong with my grid?

    Here is the GridBoundColumn for the Lastname:

    <telerik:GridBoundColumn DataField="Driver.LastName"  DataType="System.String" HeaderText="Fahrer" UniqueName="DriverLastName"  AutoPostBackOnFilter="true" ShowFilterIcon="true" AllowFiltering="true"  >
                           </telerik:GridBoundColumn>

     

    And here is the whole Radgrid:     

    <telerik:RadGrid Height="100%" runat="server" ID="RadGrid1" OnNeedDataSource="RadGrid1_NeedDataSource" AllowPaging="true" PageSize="12"
                   Font-Size="Small" AutoGenerateColumns="False" Culture="de-DE" MasterTableView-CommandItemSettings-AddNewRecordText="Reisekostenerfassung"
                   OnPreRender="RadGrid1_PreRender" OnUpdateCommand="RadGrid1_UpdateCommand" OnInsertCommand="RadGrid1_InsertCommand" OnDeleteCommand="RadGrid1_DeleteCommand" AllowFilteringByColumn="True" AllowSorting="True" >
                   <MasterTableView DataKeyNames="OperationalTravelingExpensesId" runat="server" EditMode="PopUp" CommandItemDisplay="Top" ShowHeadersWhenNoRecords="true" AllowFilteringByColumn="True">
                       <Columns>
                           <telerik:GridEditCommandColumn UniqueName="EditCommandColumn"></telerik:GridEditCommandColumn>
                           <telerik:GridBoundColumn DataField="OperationalTravelingExpensesId" HeaderText="sdf" UniqueName="OperationalTravelingExpensesId" Display="false">
                           </telerik:GridBoundColumn>
                           <telerik:GridBoundColumn DataField="Driver.LastName"  DataType="System.String" HeaderText="Fahrer" UniqueName="DriverLastName"  AutoPostBackOnFilter="true" ShowFilterIcon="true" AllowFiltering="true"  >
                           </telerik:GridBoundColumn>
                           <telerik:GridBoundColumn DataField="Driver.DriverNumber" HeaderText="Personalnr." UniqueName="DriverPersonalNumber" >
                           </telerik:GridBoundColumn>
     
                           <%--<telerik:GridBoundColumn DataField="TravelingDate" HeaderText="Datum" UniqueName="TravelingDate" DataFormatString="{0:D}" >
                           </telerik:GridBoundColumn>--%>
     
                             <telerik:GridDateTimeColumn DataField="TravelingDate" HeaderText="Datum" FilterControlWidth="110px"
                               SortExpression="Datum" PickerType="DatePicker" EnableTimeIndependentFiltering="true"
                               DataFormatString="{0:D}">
                           </telerik:GridDateTimeColumn>
     
                           <telerik:GridBoundColumn DataField="StartTime" HeaderText="Beginn" UniqueName="StartTime" DataFormatString="{0:HH:mm}" AllowFiltering="false">
                           </telerik:GridBoundColumn>
                           <telerik:GridBoundColumn DataField="EndTime" HeaderText="Ende" UniqueName="EndTime" DataFormatString="{0:HH:mm}" AllowFiltering="false">
                           </telerik:GridBoundColumn>
                           <telerik:GridBoundColumn DataField="Vehicle.LicencePlateNumber" HeaderText="Fahrzeug" UniqueName="VehicleLicencePlateNumber" AllowFiltering="false">
                           </telerik:GridBoundColumn>
                           <telerik:GridBoundColumn DataField="Tour.TourNumber" HeaderText="Tour" UniqueName="TourTourNumber">
                           </telerik:GridBoundColumn>
                           <telerik:GridBoundColumn DataField="Destination" HeaderText="Reiseziel" UniqueName="Destination" AllowFiltering="false">
                           </telerik:GridBoundColumn>
                           <telerik:GridBoundColumn DataField="Subject" HeaderText="Anlass" UniqueName="Subject" AllowFiltering="false">
                           </telerik:GridBoundColumn>
                       </Columns>
                       <EditFormSettings UserControlName="TravelExpenses.ascx" EditFormType="WebUserControl">
                           <EditColumn UniqueName="EditCommandColumn1"/>
                       </EditFormSettings>
                   </MasterTableView>
               <ClientSettings>
                   <ClientEvents OnRowDblClick="RowDblClick" OnPopUpShowing="onPopUpShowing" />
               </ClientSettings>
       </telerik:RadGrid>

     

     

  2. Attila Antal
    Admin
    Attila Antal avatar
    440 posts

    Posted 10 Oct 2019 Link to this post

    Hi Simon,

    The Column declaration you've shared is correct.

    Assuming the binding is also correct. For example, having the following models:

    class DriverModel
    {
        public string LastName { get; set; }
    }
    class Order
    {
        public int OrderID { get; set; }
        public DateTime OrderDate { get; set; }
        public string ShipCountry { get; set; }
        public DriverModel Driver { get; set; }
    }

     

    Binding a list of Orders to RadGrid:

    protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        RadGrid1.DataSource = Enumerable.Range(1, 10).Select(o => new Order()
        {
            OrderID = o,
            OrderDate = DateTime.Now.AddHours(o),
            ShipCountry = "Country " + o,
            Driver = new DriverModel()
            {
                LastName = "Driver " + o
            }
        }).ToList();
    }

     

    Using the same column you've showed us:

    <telerik:GridBoundColumn DataField="Driver.LastName" DataType="System.String" HeaderText="Fahrer" UniqueName="DriverLastName" AutoPostBackOnFilter="true" ShowFilterIcon="true" AllowFiltering="true">
    </telerik:GridBoundColumn>

     

    Results:

     

    If that is the case and the issue still persist, perhaps there are other issues.

    1. Check out the Pro Tips part under the Debug JavaScript section of the Improve Your Debugging Skills with Chrome DevTools blog post. Ensure that there are no errors present.
    2. Turn off AJAX temporarily and test the application without that: Get more descriptive errors by disabling AJAX. While developing/testing application we highly recommend doing that without having AJAX enabled. If enabled, it could hide a lot of errors generated by the server and a result of that productivity decreases and causes frustrations.
    3. Data binding is another important factor. If not used correctly, the Grid won't produce the expected results. See How to bind RadGrid properly on server-side
    4. Last, but not least, check the code behind and ensure that no Command is cancelled. The Grid has the ItemCommand event, and in the event handler avoid setting the "e.Canceled = true;" 


    Kind regards,
    Attila Antal
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. Simon
    Simon avatar
    75 posts
    Member since:
    Sep 2018

    Posted 10 Oct 2019 in reply to Attila Antal Link to this post

    Hi Attila,

    thank you.

    Perhaps the reason is I have no list as Datasource.

    It is of the type DataTable.

    I show you:

    protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
           {
               RadGrid1.DataSource = this.Employees;
               this.Employees.PrimaryKey = new DataColumn[] {                this.Employees.Columns["OperationalTravelingExpensesId"] };
           }

     

    And:

    private DataTable Employees
         {
             get
             {
                 object obj = this.Session["Employees"];
                 if ((!(obj == null)))
                 {
                     return ((DataTable)(obj));
                 }
                 DataTable myDataTable = new DataTable();
                 myDataTable = CreateDataTable<MyOperationalTravelingExpense>(OperationalTravelingExpenses);
                 this.Session["Employees"] = myDataTable;
                 return myDataTable;
             }
         }

     

  4. Simon
    Simon avatar
    75 posts
    Member since:
    Sep 2018

    Posted 11 Oct 2019 Link to this post

    UPDATE:

    I have installed Google Chrome.

    When I investigate the page I get some errors.

    "Driver.LastName is no datacoloumn or datarelation for the table."

    For me it says nothing.

    By the way:

    I have generate a new project with your above codeexample and the filtering is working.

    But no idea what is going wrong with my project.

    Best regards

     

    Simon

  5. Attila Antal
    Admin
    Attila Antal avatar
    440 posts

    Posted 15 Oct 2019 Link to this post

    Hi Simon,

     

    1. From the screenshot I can see that AJAX is still enabled. Please make sure to turn it off by following the instructions I have mentioned in my previous post. Specially when troubleshooting. Although it's a good practice to have it turned off for as long the application is being developed. AJAX is not required for an application to work, and so, having it enabled would only slow down the development process.

    2. Judging by the error message,  the Grid is trying to access LastName property of Driver object which doesn't exist. Regardless of the DataSource type (List or DataTable), you will need to ensure that the Object and its referenced properties are available.

     

    Markup

     

    <telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource" AllowFilteringByColumn="true">
        <MasterTableView AutoGenerateColumns="false">
            <Columns>
                <telerik:GridBoundColumn DataField="OrderID" DataType="System.Int32"
                    FilterControlAltText="Filter OrderID column" HeaderText="OrderID"
                    ReadOnly="True" SortExpression="OrderID" UniqueName="OrderID">
                </telerik:GridBoundColumn>
    
                <telerik:GridBoundColumn DataField="ShipCountry"
                    FilterControlAltText="Filter ShipCountry column" HeaderText="ShipCountry"
                    SortExpression="ShipCountry" UniqueName="ShipCountry">
                </telerik:GridBoundColumn>
    
                <telerik:GridBoundColumn DataField="Driver.FirstName"
                    FilterControlAltText="Driver FirstName" HeaderText="Driver FirstName"
                    SortExpression="Driver.FirstName" UniqueName="DriverFirstName">
                </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Driver.LastName"
                    FilterControlAltText="Driver LastName" HeaderText="Driver LastName"
                    SortExpression="Driver.LastName" UniqueName="DriverLastName">
                </telerik:GridBoundColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>

     

     

    C#

    protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        // DataTable
        RadGrid1.DataSource = GetGridSource();
    
        // List
        RadGrid1.DataSource = Enumerable.Range(1, 3).Select(x => new
        {
            OrderID = x,
            ShipCountry = "Country " + x,
            Driver = new Driver()
            {
                Id = 1,
                FirstName = "First " + x,
                LastName = "Last " + x
            }
        });
    }
    
    // DataTable
    private DataTable GetGridSource()
    {
        DataTable dt = new DataTable();
    
        dt.Columns.Add(new DataColumn("OrderID", typeof(int)));
        dt.Columns.Add(new DataColumn("ShipCountry", typeof(string)));
        dt.Columns.Add(new DataColumn("Driver", typeof(Driver)));
    
        dt.PrimaryKey = new DataColumn[] { dt.Columns["OrderID"] };
    
        for (int i = 0; i < 3; i++)
        {
            int index = i + 1;
    
            DataRow row = dt.NewRow();
    
            row["OrderID"] = index;
            row["ShipCountry"] = "Country " + index;
            row["Driver"] = new Driver()
            {
                Id = 1,
                FirstName = "First " + index,
                LastName = "Last " + index
            };
    
            dt.Rows.Add(row);
        }
    
        return dt;
    }
    
    // Driver model
    class Driver
    {
        public int Id { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
    }

     

    Result:

     

     

    Kind regards,
    Attila Antal
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  6. Simon
    Simon avatar
    75 posts
    Member since:
    Sep 2018

    Posted 15 Oct 2019 Link to this post

    Hi Attila,

    but the object Driver exists, because the lastnames are displayed in the table.

    That's just the joke at the thing, that the lastnames are displayed but not filterable.

    It is better when I show you the frontend:

    Please see the attached files radgridView_1.jpg, radgridView_2.jpg and radgridView_3.jpg !

    ...and I have AJAX disabled as you can see, but filtering still not working.

    <telerik:RadGrid Height="100%" runat="server"  ID="RadGrid1" EnableLinqExpressions="false" OnNeedDataSource="RadGrid1_NeedDataSource" EnableAJAX="false" AllowPaging="True" PageSize="12"
                   Font-Size="Small" AutoGenerateColumns="False" Culture="de-DE" MasterTableView-CommandItemSettings-AddNewRecordText="Reisekostenerfassung"
                   OnPreRender="RadGrid1_PreRender" OnUpdateCommand="RadGrid1_UpdateCommand" OnInsertCommand="RadGrid1_InsertCommand" OnDeleteCommand="RadGrid1_DeleteCommand" AllowFilteringByColumn="True" AllowSorting="True" >
                   <MasterTableView  runat="server"  AutoGenerateColumns="false" >

     

     

    Best Regards

     

    Simon

  7. Attila Antal
    Admin
    Attila Antal avatar
    440 posts

    Posted 15 Oct 2019 Link to this post

    Hi Simon,

    Disabling AJAX is not done through the Grid declaration. Check out the article I have shared earlier and follow the instructions there. Once AJAX is disabled, you will see all server errors in details, if any is generated.

    Please follow the first 3 points from my first response and test the application again. If the issue still persist, share the complete markup of the Grid including the column declarations as well as all the code behind that is related to RadGrid.

    You can also compare my code snippets to the code you have at your side and see what is done differently. Most likely the Grid at your side is configured differently and that's the reason the filtering is not working.

    Kind regards,
    Attila Antal
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  8. Simon
    Simon avatar
    75 posts
    Member since:
    Sep 2018

    Posted 16 Oct 2019 Link to this post

     

    Here is my markup:

    <asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
     
     
     
            <script type="text/javascript">
     
                function openNewWindow(sender, args)
            {
                var item = args.get_item();
                var itemUrl = item.get_value();
                var itemText = item.get_text();
                if (itemUrl) {
                    //var windowUrl = itemUrl;
                    var oWnd = radopen(itemUrl, "");
                    oWnd.set_title(itemText);
                    oWnd.center();
                }
            }
                function RowDblClick(sender, eventArgs) {
                    sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
                }
     
                function onPopUpShowing(sender, args) {
                    args.get_popUp().className += " popUpEditForm";
                }
            </script>
        </telerik:RadCodeBlock>
           <%-- <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="ConfiguratorPanel">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
        </telerik:RadAjaxLoadingPanel>--%>
     
        <telerik:RadToolBar runat="server" ID="RadToolBar1" CssClass="secondaryMenu" Skin="BlackMetroTouch">
        </telerik:RadToolBar>
     
         <telerik:RadFormDecorator RenderMode="Lightweight" ID="RadFormDecorator1" runat="server" DecorationZoneID="demo" DecoratedControls="All" EnableRoundedCorners="false" />
        <div id="demo" class="demo-container no-bg">
     
                <telerik:RadGrid Height="100%" runat="server"  ID="RadGrid1"  OnNeedDataSource="RadGrid1_NeedDataSource" EnableAJAX="false" AllowPaging="True" PageSize="12"
                    Font-Size="Small" AutoGenerateColumns="False" Culture="de-DE" MasterTableView-CommandItemSettings-AddNewRecordText="Reisekostenerfassung"
                    OnPreRender="RadGrid1_PreRender" OnUpdateCommand="RadGrid1_UpdateCommand" OnInsertCommand="RadGrid1_InsertCommand" OnDeleteCommand="RadGrid1_DeleteCommand" AllowFilteringByColumn="True" AllowSorting="True" >
                    <MasterTableView  runat="server"  AutoGenerateColumns="false" EnableColumnsViewState="false">
                        <Columns>
                            <telerik:GridEditCommandColumn UniqueName="EditCommandColumn"></telerik:GridEditCommandColumn>
                            <telerik:GridBoundColumn DataField="OperationalTravelingExpensesId" HeaderText="sdf" UniqueName="OperationalTravelingExpensesId" Display="false">
                            </telerik:GridBoundColumn>
     
                           <%-- <telerik:GridBoundColumn DataField="Driver.LastName"   FilterControlAltText="Filter DriverLastName column"  DataType="System.String" HeaderText="Fahrer" UniqueName="DriverLastName"  FilterDelay="2000"  AutoPostBackOnFilter="true" ShowFilterIcon="false" CurrentFilterFunction="Contains"  >
                            </telerik:GridBoundColumn>   --%>     
                             
                            <telerik:GridBoundColumn DataField="Driver.LastName" FilterControlAltText="Driver LastName" HeaderText="Fahrer" SortExpression="LastName" UniqueName="LastName">
                              </telerik:GridBoundColumn>
                              
     
                            <telerik:GridBoundColumn DataField="Driver.DriverNumber" HeaderText="Personalnr." UniqueName="DriverPersonalNumber" FilterDelay="2000" AutoPostBackOnFilter="true" ShowFilterIcon="false" CurrentFilterFunction="Contains"   >
                            </telerik:GridBoundColumn>
     
                            <%--<telerik:GridBoundColumn DataField="TravelingDate" HeaderText="Datum" UniqueName="TravelingDate" DataFormatString="{0:D}" >
                            </telerik:GridBoundColumn>--%>
     
                              <telerik:GridDateTimeColumn DataField="TravelingDate" HeaderText="Datum" FilterControlWidth="110px"
                                SortExpression="Datum" PickerType="DatePicker" EnableTimeIndependentFiltering="true"
                                DataFormatString="{0:D}">
                            </telerik:GridDateTimeColumn>
     
                            <telerik:GridBoundColumn DataField="StartTime" HeaderText="Beginn" UniqueName="StartTime" DataFormatString="{0:HH:mm}" AllowFiltering="false">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="EndTime" HeaderText="Ende" UniqueName="EndTime" DataFormatString="{0:HH:mm}" AllowFiltering="false">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Vehicle.LicencePlateNumber" HeaderText="Fahrzeug" UniqueName="VehicleLicencePlateNumber" AllowFiltering="false">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Tour.TourNumber" HeaderText="Tour" UniqueName="TourTourNumber" FilterDelay="2000" AutoPostBackOnFilter="true" ShowFilterIcon="false" CurrentFilterFunction="EqualTo"  >
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Destination" HeaderText="Reiseziel" UniqueName="Destination" AllowFiltering="false">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Subject" HeaderText="Anlass" UniqueName="Subject" AllowFiltering="false">
                            </telerik:GridBoundColumn>
                        </Columns>
                        <EditFormSettings UserControlName="TravelExpenses.ascx" EditFormType="WebUserControl">
                            <EditColumn UniqueName="EditCommandColumn1"/>
                        </EditFormSettings>
                    </MasterTableView>
                <ClientSettings>
                    <ClientEvents OnRowDblClick="RowDblClick" OnPopUpShowing="onPopUpShowing" />
                </ClientSettings>
        </telerik:RadGrid>
     
            </div>
    </asp:Content>

     

    I commented out that AJAX stuff, but when I try to filter I get an error message(german) below:

    Serverfehler in der Anwendung /.
    Driver.LastName ist keine DataColumn oder DataRelati     on für die Tabelle .
    Beschreibung: Unbehandelte Ausnahme beim Ausführen der aktuellen Webanforderung. Überprüfen Sie die Stapelüberwachung, um weitere Informationen über diesen Fehler anzuzeigen und festzustellen, wo der Fehler im Code verursacht wurde.
     
    Ausnahmedetails: System.ArgumentException: Driver.LastName ist keine DataColumn oder DataRelation für die Tabelle .
     
    Quellfehler:
     
    Beim Ausführen der aktuellen Webanforderung wurde einen unbehandelte Ausnahme generiert. Informationen über den Ursprung und die Position der Ausnahme können mit der Ausnahmestapelüberwachung angezeigt werden.
     
    Stapelüberwachung:
     
     
    [ArgumentException: Driver.LastName ist keine DataColumn oder DataRelation für die Tabelle .]
       System.Data.DataRowView.get_Item(String property) +138
       lambda_method(Closure , DataRowView ) +18
       System.Linq.WhereEnumerableIterator`1.MoveNext() +141
       System.Linq.Enumerable.Count(IEnumerable`1 source) +191
       lambda_method(Closure ) +152
       System.Linq.EnumerableExecutor`1.Execute() +96
       System.Linq.EnumerableExecutor`1.ExecuteBoxed() +23
       System.Linq.EnumerableQuery`1.System.Linq.IQueryProvider.Execute(Expression expression) +89
       Telerik.Web.UI.GridDynamicQueryable.Count(IQueryable source) +144
       Telerik.Web.UI.GridDataTableFromEnumerable.FillData35() +2717
       Telerik.Web.UI.GridDataTableFromEnumerable.FillData() +679
       Telerik.Web.UI.GridResolveEnumerable.Initialize() +35
       Telerik.Web.UI.GridResolveEnumerable.EnsureInitialized() +24
       Telerik.Web.UI.GridEnumerableFromDataView..ctor(GridTableView owner, DataView dataView, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields, Boolean enableSplitHeaderText) +206
       Telerik.Web.UI.GridDataSourceHelper.CreateGridEnumerable(GridTableView owner, IEnumerable enumerable, Boolean caseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields, Boolean enableSplitHeaderText) +71
       Telerik.Web.UI.GridDataSourceHelper.GetResolvedDataSource(GridTableView owner, Object dataSource, String dataMember, Boolean caseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields, Boolean enableSplitHeaderText) +202
       Telerik.Web.UI.GridTableView.get_ResolvedDataSource() +170
       Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) +372
       System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +67
       System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +153
       System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +29
       System.Web.UI.WebControls.DataBoundControl.PerformSelect() +170
       Telerik.Web.UI.GridTableView.PerformSelect() +16
       System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +71
       Telerik.Web.UI.GridTableView.DataBind() +287
       Telerik.Web.UI.GridTableView.Rebind() +118
       Telerik.Web.UI.GridFilterCommandEventArgs.ExecuteCommand(Object source) +638
       Telerik.Web.UI.RadGrid.OnBubbleEvent(Object source, EventArgs e) +91
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
       Telerik.Web.UI.GridItem.OnBubbleEvent(Object source, EventArgs e) +39
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
       Telerik.Web.UI.GridItem.OnBubbleEvent(Object source, EventArgs e) +89
       Telerik.Web.UI.GridItem.FireCommandEvent(String commandName, Object commandArgument) +52
       Telerik.Web.UI.RadGrid.RaisePostBackEvent(String eventArgument) +8908
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +169
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3467     
    protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs
    private DataTable Employees
          {
              get
              {
                  object obj = this.Session["Employees"];
                  if ((!(obj == null)))
                  {
                      return ((DataTable)(obj));
                  }
                  DataTable myDataTable = new DataTable();
                  myDataTable = CreateDataTable<MyOperationalTravelingExpense>(OperationalTravelingExpenses);
                  this.Session["Employees"] = myDataTable;
                  return myDataTable;
              }
          }
    public static DataTable CreateDataTable<T>(IEnumerable<T> list)
          {
              Type type = typeof(T);
              var properties = type.GetProperties();
     
              DataTable dataTable = new DataTable();
              foreach (PropertyInfo info in properties)
              {
                  dataTable.Columns.Add(new DataColumn(info.Name, Nullable.GetUnderlyingType(info.PropertyType) ?? info.PropertyType));
              }
     
              foreach (T entity in list)
              {
                  object[] values = new object[properties.Length];
                  for (int i = 0; i < properties.Length; i++)
                  {
                      values[i] = properties[i].GetValue(entity);
                  }
     
                  dataTable.Rows.Add(values);
              }
     
              return dataTable;
          }
    e)
            {
     
                RadGrid1.DataSource = this.Employees;
                //this.Employees.PrimaryKey = new DataColumn[] { this.Employees.Columns["OperationalTravelingExpensesId"] };
            }
  9. Attila Antal
    Admin
    Attila Antal avatar
    440 posts

    Posted 17 Oct 2019 Link to this post

    Hi Simon,

    I have attached a runnable sample that works with Sub-Objects and DataTables. (Telerik assemblies not included)

    Please modify this sample to replicate the error and share it with us so that we can see what is happening.

    Kind regards,
    Attila Antal
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  10. Simon
    Simon avatar
    75 posts
    Member since:
    Sep 2018

    Posted 18 Oct 2019 in reply to Attila Antal Link to this post

     

    Hi Attila,

    thank you for your shared sample, it works!

    But there is a difference in the project templates.

    My project template in Visual Studio is a webapplication not a website!

    And therefore I have a MasterPage file.

    Very interesting: When I copy and paste my radgrid from my project in your sample it works too!

    Perhaps the MasterPage is the problem.

    The radgrid is in the maincontent (ContentPlaceHolder ID="MainContent" )

    Here is my MasterPage:

    <%@ Master Language="C#" AutoEventWireup="true" ClientIDMode="Predictable" CodeFile="MasterPage.Master.cs" Inherits="MasterPage" %>
     
    <!DOCTYPE html>
    <head id="Head1" runat="server">
        <title>Lewin</title>
        <link rel="stylesheet" type="text/css" href="Styles/main.css" />
        <link rel="icon" href="Images/aioIcon.bmp" />
     
        <asp:ContentPlaceHolder ID="head" runat="server">
        </asp:ContentPlaceHolder>
        <meta http-equiv="Pragma" content="no-cache"/>
        <meta name="viewport" content="width=device-width, initial-scale=1" />
    </head>
    <body>
        <form id="form1" class="clear" runat="server">
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
                <Scripts>
                    <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                    <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                    <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
                </Scripts>
            </telerik:RadScriptManager>
     
            <div id="about" class="slider">
                <header class="tm-header" id="logo"></header>
                <h2 class="logo">
                    <img src="Images/image003.png" alt="Telerik WEB.UI for ASP.NET AJAX" />
                </h2>
     
                <telerik:RadMenu runat="server" ID="verticalMenu2" Skin="BlackMetroTouch" Flow="Vertical" CssClass="main-menu" EnableImageSprites="true" RenderMode="Lightweight">
                    <Items>
                        <telerik:RadMenuItem Text="TPS" NavigateUrl="default.aspx" CssClass="mail" />
                        <telerik:RadMenuItem Text="FMS" NavigateUrl="" CssClass="contacts" />
                        <telerik:RadMenuItem Text="Kalender" NavigateUrl="calendar.aspx" CssClass="calendar" />
                        <telerik:RadMenuItem Text="Stammdaten" NavigateUrl="basedata.aspx" CssClass="notes" />
                        <telerik:RadMenuItem Text="Reports" NavigateUrl="reports.aspx" CssClass="notes" />
                        <telerik:RadMenuItem Text="Fahrermanagement" NavigateUrl="DriverManagement.aspx" CssClass="notes" />
                        <%--<telerik:RadMenuItem Text="Reports" NavigateUrl="default.aspx" CssClass="notes" />--%>
     
                    </Items>
                </telerik:RadMenu>
     
                <%--<telerik:RadMenu ID="RadMenu1" runat="server" CssClass="help-menu" Skin="BlackMetroTouch" Flow="Vertical" RenderMode="Lightweight">
                    <Items>
                        <telerik:RadMenuItem Text="LIVE WEBMAIL APP" NavigateUrl="https://demos.telerik.com/aspnet-ajax/webmail/" Target="_blank" />
                    </Items>
                </telerik:RadMenu>--%>
            </div>
            <div class="page">
                <div class="main-header clear">
                    <div class="home-btn">
                        <span class="icon icon-Home"></span>
                        <span class="text"><%: Page.Title %></span>
                    </div>
     
                    <telerik:RadNavigation ID="mainNavigation" runat="server" CssClass="header-info" EnableEmbeddedSkins="false">
                        <Nodes>
                            <%--<telerik:NavigationNode Text="LIVE WEBMAIL APP" NavigateUrl="https://demos.telerik.com/aspnet-ajax/webmail/" Target="_blank" SpriteCssClass="icon icon-Info" />
                            <telerik:NavigationNode Text="DOWNLOAD" NavigateUrl="https://demos.telerik.com/aspnet-ajax/webmail/webmailsource.zip" SpriteCssClass="icon icon-Download" />--%>
                            <telerik:NavigationNode Text="Kunde Name  TPS" CssClass="user" SpriteCssClass="icon icon-Arrow-South"></telerik:NavigationNode>
                        </Nodes>
                    </telerik:RadNavigation>
                </div>
                <div class="container clear">
                    <div class="sidebar" id="sidebar">
                        <asp:ContentPlaceHolder ID="FolderContent" runat="server">
                        </asp:ContentPlaceHolder>
                    </div>
     
                    <div class="section bottom">
                        <asp:ContentPlaceHolder ID="MainContent" runat="server">
                        </asp:ContentPlaceHolder>
                    </div>
     
                    <div class="bottom lists">
                        <asp:ContentPlaceHolder ID="BottomContent" runat="server">
                        </asp:ContentPlaceHolder>
                    </div>
                </div>
                <div class="tm-click-overlay"></div>
                <telerik:RadToolTip runat="server" ID="UserProfile" IsClientID="true" EnableShadow="true" HideEvent="FromCode" Visible="true" TargetControlID="aa">
                    <img src="Images/aioIcon.bmp" alt="" />
                    <div class="content">
                        <span>kunde@aio.de</span>
                        <span class="addBtn">
                            <span class="icon icon-Add-Circle"></span>
                            <span class="text">Info</span>
                        </span>
                        <telerik:RadButton runat="server" ID="SignOut" ButtonType="LinkButton" Text="Ausloggen"></telerik:RadButton>
                    </div>
                </telerik:RadToolTip>
            </div>
            <asp:HiddenField runat="server" ID="nav" />
     
            <script type="text/javascript">
                var nav = $get("<%= nav.ClientID %>").value;
     
                function pageLoad() {
                    if (nav === "mobile") {
                        $itemMenu = $(".item.menu");
     
                        $('.rmRootToggle').on("click", function () {
                            var open = $itemMenu.hasClass("expanded");
                            if (!open)
                                $itemMenu.addClass("expanded");
                            else
                                $itemMenu.removeClass("expanded");
                        });
                    }
     
                    $('.home-btn').on("click", function () {
                        $('form').toggleClass('expandedSlider');
                    });
     
                    setNavigationsMinWidth();
                    initializeInteractions();
                }
     
                function initializeInteractions() {
                    $(".user").on("click", function (e) {
                        toggleToolTip(e);
                    })
     
                    $(".searchBtn").on("click", function () {
                        showSearch();
                    })
                }
     
                function setNavigationsMinWidth() {
                    $(".RadNavigation").each(function () {
                        var navigation = $find($(this).attr("id"));
                        navigation._minWidth = 0;
                        navigation.repaint()
                    })
                }
     
                function toggleToolTip(e) {
                    var tooltip = $find("<%=UserProfile.ClientID %>");
     
                    if (!tooltip.isVisible() == true) {
                        var $node = $(e.currentTarget);
                        var arrowPosition = $node.offset();
     
                        tooltip.show();
                        var popup = tooltip.get_popupElement();
     
                        positionX = arrowPosition.left - $(popup).outerWidth(true) + $node.outerWidth(true) + 5;
                        positionY = arrowPosition.top + $node.outerHeight(true) + 3;
     
                        setTimeout(function () {
                            $telerik.setLocation(popup, { x: positionX, y: positionY });
                        }, 20)
     
                        $("html").on("click", function (e) {
                        })
                    }
                    else {
                        tooltip.hide();
                    }
                }
     
                function showSearch() {
                    var search = $find($('div.RadSearchBox').attr('id'));
                    var $search = $(search.get_element());
                    var $searchInput = $search.find(".rsbInput");
                    $search.removeClass("hidden");
                    $searchInput.focus();
     
                    setTimeout(function () {
                        search.repaint();
     
                        $('html').on("click", function (e) {
                            hideSearch(e, $search);
                        });
                    }, 300);
     
                }
     
                function hideSearch(e, $search) {
                    var isSearchBoxClicked = $(e.target).parents(".RadSearchBox").length == 1;
                    var isSearchBoxItemClicked = $(e.target).parents(".rsbPopup").length == 1;
     
                    if (isSearchBoxClicked || isSearchBoxItemClicked) {
                        return
                    }
     
                    $search.addClass("hidden");
                    $('html').off("click");
                }
            </script>
        </form>
    </body>
    </html>

         

  11. Attila Antal
    Admin
    Attila Antal avatar
    440 posts

    Posted 22 Oct 2019 Link to this post

    Hi Simon,

    We're always using Web Site project when troubleshooting an issue. The biggest advantage that it does need to be built every time you make a change as opposed to a Web Application project. You can check out the following article discussing the main differences briefly: ASP.NET Web Site or ASP.NET Web Application?

    For simple scenarios, a Web Site project will do just as well as an Application would, and the difference will not be noticeable except that you will need to build it before the changes can be displayed in the browser. If you create a test page in the Application project and only copy the source code from my sample, that will also work. 

    Speaking of building, I was thinking maybe you have changed things but the build was not done, or not complete for some reason. That is something you will need to double check before opening the page.

    In any case, I would require a runnable sample project that produces the error so that I can debug it and see why things aren't working.

    Try isolating the issue in a sample project and share it with me.

    Kind regards,
    Attila Antal
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top