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

[Solved] Javascript Error in grouping

1 Answer 132 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Dadv
Top achievements
Rank 1
Dadv asked on 21 Jun 2011, 03:59 PM
Hi, in the exemple project for Grouping I change the code like this :

<%= Html.Telerik().Grid<Order>(Model)
        .Name("Grid")
        .Columns(columns =>
        {
            columns.Bound(o => o.OrderID).Width(100);
            columns.Bound(o => o.Customer.ContactName).Width(200).Visible(!(bool)ViewData["contactName"]); //Make the columns not visible if it's group
            columns.Bound(o => o.ShipAddress).Visible(!(bool)ViewData["shipAddress"]);//Make the columns not visible if it's group
            columns.Bound(o => o.OrderDate).Format("{0:MM/dd/yyyy}").Width(120).Visible(!(bool)ViewData["orderDate"]);//Make the columns not visible if it's group
        })
        .Groupable(settings => settings.Groups(groups =>
        {
            if ((bool)ViewData["orderDate"])
            {
                groups.Add(o => o.OrderDate);
            }
             
            if ((bool)ViewData["shipAddress"])
            {
                groups.Add(o => o.ShipAddress);
            }
             
            if ((bool)ViewData["contactName"])
            {
                groups.Add(o => o.Customer.ContactName);
            }
        }))
        .DataBinding(dataBinding => dataBinding.Ajax().Select("GroupingAjax", "Grid"))
        .Scrollable()
        .Sortable()
        .Pageable()
        .Filterable()
%>


Now if i try to move grouping block , i have a javascript error : title is null or is not an object (translate from French)

If Visible is true, no error is throw.

How can i have this error fix please?

Thx for the answer

1 Answer, 1 is accepted

Sort by
0
Dadv
Top achievements
Rank 1
answered on 22 Jun 2011, 10:12 AM
Using CustomBinding and making columns hidden fix partially the problem : 


[SourceCodeFile("Binding Helper", "~/Extensions/CustomBindingExtensions.cs")]
 [GridAction(GridName = "Grid")]
 public ActionResult CustomServerBinding(GridCommand command)
 {
     ViewData["orderDate"] = command.GroupDescriptors.Any(g => g.Member == "OrderDate"); // Add for the test
     ViewData["shipAddress"] = command.GroupDescriptors.Any(g => g.Member == "ShipAddress"); // Add for the test
     ViewData["contactName"] = command.GroupDescriptors.Any(g => g.Member == "Customer.ContactName"); // Add for the test
 
     IEnumerable data = GetServerData(!IsEmptyCommand(command) ? command : new GridCommand());
     return View(data);
 }


<%= Html.Telerik().Grid<Order>()
        .Name("Grid")
        .BindTo(Model)
        .Columns(columns =>
        {
            columns.Bound(o => o.OrderID).Width(100);
             
            // THIS DON'T WORK ????
            //columns.Bound(o => o.Customer.ContactName).Width(200).Hidden((bool)ViewData["contactName"]);
 
            // THIS WORK FINE
            var c1 =columns.Bound(o => o.Customer.ContactName).Width(200);
            if((bool)ViewData["contactName"])
                c1.Hidden();
             
            // THIS DON'T WORK ????
            //columns.Bound(o => o.ShipAddress).Hidden((bool)ViewData["shipAddress"]);
             
            // THIS WORK FINE
            var c2 =columns.Bound(o => o.ShipAddress).Hidden((bool)ViewData["shipAddress"]);
            if ((bool)ViewData["shipAddress"])
                c2.Hidden();
 
 
            // THIS DON'T WORK ????
            //columns.Bound(o => o.OrderDate).Format("{0:MM/dd/yyyy}").Width(100).Hidden((bool)ViewData["orderDate"]);
 
            // THIS WORK FINE
            var c3 = columns.Bound(o => o.OrderDate).Format("{0:MM/dd/yyyy}").Width(100);
            if ((bool)ViewData["orderDate"])
                c3.Hidden();
        })
        .DataBinding(dataBinding => dataBinding.Server().Select("CustomServerBinding", "Grid"))
        .Pageable(settings => settings.Total((int)ViewData["total"]))
        .EnableCustomBinding(true)
        .Sortable()
        .Filterable()
        .Groupable()
%>



I don't understand why this don't work fine :  columns.Bound(o => o.Customer.ContactName).Width(200).Hidden((bool)ViewData["contactName"]);

It's like .Hidden(false) = .Hidden(true) .....

Is this a bug?

Thx for the answer.
Tags
Grid
Asked by
Dadv
Top achievements
Rank 1
Answers by
Dadv
Top achievements
Rank 1
Share this question
or