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

[Solved] Grid - Sortable & Filterable doesn't work?

5 Answers 133 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.
Kenny
Top achievements
Rank 1
Kenny asked on 13 Nov 2009, 08:03 PM
Hello all,
I'm binding the Grid to a ViewModel class, everything is working just fine, including Pageable. But enabling "Sortable()" and/or "Filterable()" doesn't do anything to it. The Grid data was populated from a LINQ2SQL class, pretty straightforward stuffs I think.
Here's the code:
<% Html.Telerik().Grid<NotesnhacLib.Song>(Model.TypeDetailsModel.SongsFromThisType) 
       .Name("Songs") 
       .Columns(columns => 
       { 
           columns.Add(c => 
           { 
               %> 
               <%= Html.ActionLink(c.SongTitle, "Details", "Song", new { id = c.SongId, songTitle = KennyLib.Utilities.ToFriendlyUrl(c.SongTitle2)}, null) %> 
               <
           }).Title("Title").Width(325); 
           columns.Add(c => 
           { 
               %> 
               <%= Html.ActionLink(c.Artist.ArtistName, "Artist", "Song", new { id = c.ArtistId, artistName = KennyLib.Utilities.ToFriendlyUrl(c.Artist.ArtistName2)}, null) %> 
               <
           }).Title("Artist"); 
       }) 
       .Pageable() 
       .Sortable() 
       .PrefixUrlParameters(false) 
       .Render();%> 

Any idea why it doesn't work?

Thank you very much,
Kenny.

5 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 16 Nov 2009, 09:29 AM
Hello Kenny,

Unfortunately I am not able to find where could be the problem depending on the given information. I suppose that you are using server binding. Please review this online demo and verify that your test project implements server binding correctly.

If the problem still persists I will ask you to send us enough information (View, controller, model) in order to reproduce your scenario.

Greetings,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Kenny
Top achievements
Rank 1
answered on 16 Nov 2009, 04:39 PM
Hi Georgi,
I've includes the view, controller and model here so you can have a better look:

View:
<% Html.Telerik().Grid<NotesnhacLib.Song>(Model.TypeDetailsModel.SongsFromThisType) 
       .Name("Songs") 
       .Columns(columns => 
       { 
           columns.Add(c => 
           { 
               %> 
               <%= Html.ActionLink(c.SongTitle, "Details", "Song", new { id = c.SongId, songTitle = KennyLib.Utilities.ToFriendlyUrl(c.SongTitle2)}, null) %> 
               <
           }).Title("Title").Width(325); 
           columns.Add(c => 
           { 
               %> 
               <%= Html.ActionLink(c.Artist.ArtistName, "Artist", "Song", new { id = c.ArtistId, artistName = KennyLib.Utilities.ToFriendlyUrl(c.Artist.ArtistName2)}, null) %> 
               <
           }).Title("Artist"); 
       }) 
       .Pageable() 
       .Sortable() 
       .PrefixUrlParameters(false) 
       .Render();%> 

Controller:
[AcceptVerbs(HttpVerbs.Get)] 
public ActionResult Type(int id, string songType) 
    if (!sr.CheckCategoryExists(id)) 
        return RedirectToAction("Index"); 
 
    var model = new TypeViewModel 
    { 
        TypeDetailsModel = new TypeDetailsModel 
        { 
            Category = sr.RetrieveCategory(id), 
            SongsFromThisType = sr.RetrieveSongsByCategoryId(id) 
        } 
    }; 
    return View(model); 

Model:
namespace NotesnhacWeb.Models 
    public class TypeViewModel 
    { 
        public TypeDetailsModel TypeDetailsModel { getset; } 
    } 
 
    public class TypeDetailsModel 
    { 
        public SongCategory Category { getset; } 
        public IQueryable<Song> SongsFromThisType { getset; } 
    } 

SongRepository:
public IQueryable<Song> RetrieveSongsByCategoryId(Int32 categoryId) 
        { 
            return dc.Songs.Where(s => s.SongCategoryId == categoryId).OrderBy(s => s.SongView); 
        } 

Thank you very much,
Kenny.
0
Georgi Krustev
Telerik team
answered on 17 Nov 2009, 01:37 PM
Hello Kenny,

Sorting and filtering currently is not supported with template columns. This is mentioned in the description of  templates demo.

Kind regards,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Kenny
Top achievements
Rank 1
answered on 17 Nov 2009, 03:27 PM
Hi Georgi, sorry I've overlooked that section! Is there a way to accomplish something similar to what I currently have (basically an ActionLink to another action) and still be able to have sorting ability?

Thanks,
Kenny.
0
Accepted
Georgi Krustev
Telerik team
answered on 18 Nov 2009, 04:41 PM
Hi Kenny,

Please excuse me for the misunderstanding. Here is a help topic which covers your needs. Please review it and let me know if I can assist you further.

Kind regards,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Kenny
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Kenny
Top achievements
Rank 1
Share this question
or