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

[Solved] Grid in tab

4 Answers 125 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.
Michael
Top achievements
Rank 1
Michael asked on 10 Mar 2011, 06:11 AM
I have a Hierarchial grid nested in a tabstrip, but I am having trouble with the routing, every time i press anything on the grid for filtering etc it causes a postback & the page renders on tab 1 (which is not the grid tab). When I then navigate to the "grid" tab the previously expanded detail is minimised (since the routing has been lost im guessing??)

How do I overcome this?

the URL from say a field reordering is currently www./Races?Results_142_orderBy=ActualTime-asc

whereas it should include:

Races#TabStrip-1  (I think)

4 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 10 Mar 2011, 09:28 AM
Hello Michael,

 Is the grid properly configured for ajax binding? This is mandatory if you want to maintain the selected tab. Otherwise the tabstrip will always display the initially selected tab.

 You can check this example for a working implementation.

Regards,
Atanas Korchev
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Michael
Top achievements
Rank 1
answered on 11 Mar 2011, 08:26 AM
OK
That all works well...thank you (although now the child grid isn't displaying the data correctly)

these were all working when i had the grids set up from server viewmodel like:
.DetailView(ordersDetailView => ordersDetailView.Template(o => OrdersDetailViewTemplate(this, o)))

The columns are all TimeSpans
  • I have checked the data and it is in the returned object from the ActionResult
  • The UserName String is returned successfully
  • The columns display [object Object]

Im guessing it has someting to do with JSON & timespans??

I can change the viewmodel to return strings, but it seems an awkward work around?

the column code is:

.Columns(columns =>
   {
       columns.Bound(o => o.FullName).Width(140);
       columns.Bound(o => o.ActualTime).Width(140).Format("{0:hh\\:mm\\:ss}");
       columns.Bound(o => o.HandicapTime).Width(200).Format("{0:hh\\:mm\\:ss}");
       columns.Bound(o => o.rHandicap).Width(100).Format("{0:mm\\:ss}");
   })
0
Atanas Korchev
Telerik team
answered on 11 Mar 2011, 10:02 AM
Hi Michael, 

A .NET TimeSpan is serialized as a complex object in JSON format:

{
"TimeSpan": {
    "Ticks":629731584000000000,
    "Days":728856,
    "Hours":0,
    "Milliseconds":0,
    "Minutes":0,
    "Seconds":0,
    "TotalDays":728856,
    "TotalHours":17492544,
    "TotalMilliseconds":62973158400000,
    "TotalMinutes":1049552640,
    "TotalSeconds":62973158400
    }
}

The grid displays all complex objects as [object Object] unless a ClientTemplate is not specified. This is also the reason Format does not work for timespans during ajax binding.

I can suggest one of the following workarounds:
  1. Convert the TimeSpan to string. You can format it on the server side. The grid will display it properly.
  2. Convert the TimeSpan to a DateTime .NET object. Format will work properly then.
  3. Create a ClientTemplate which is aware of the way a TimeSpan is serialized and display it:
    column.Bound(c => c.ActualTime).ClientTemplate("<#= ActualTime.Hours #>:<#= ActualTime.Minutes#>:<#= ActualTime.Seconds #>")

I hope this helps,
Atanas Korchev
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Michael
Top achievements
Rank 1
answered on 11 Mar 2011, 12:58 PM
Thanks

String sounds the simplest!!

Thanks again
Tags
Grid
Asked by
Michael
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Michael
Top achievements
Rank 1
Share this question
or