Reputation: 239
The Telerik MVC grid I am using is shown below. The data is displaying in the grid but the filterable attribute is not working, though the "Filter Icon" is displaying. I have registered the scripts and css in the layout.cshtml but I dont know why the filterable action is not working and sometimes the Column Widths are ignored and the grid is rendering in a default size.
@model IEnumerable<Customers>
@(Html.Telerik()
.Grid(Model)
.Name("Customers")
.PrefixUrlParameters(false)
.Columns(columns=>
{
columns.Bound(c => c.CustomerId).Title("CustomerId").Width(50);<br/>
columns.Bound(c => c.CustomerStatus).Title("Customer Status").Width(70);
columns.Bound(c=>c.CityId).Title("CityID").Width(50);
}
.Filterable()
.Sortable(sort=>sort.SortMode(GridSortMode.MultipleColumn))
)
layout.cshtml (registered scripts and stylesheets):
@(Html.Telerik().StyleSheetRegistrar().DefaultGroup(group => group.Add("telerik.common.css").Add("telerik.vista.css").Combined(true).Compress(true)))
@(Html.Telerik().ScriptRegistrar().Globalization(true).DefaultGroup(group => group.Combined(true).Compress(true)))
Upvotes: 1
Views: 4575
Reputation: 11
Telerik grids really are terrible. If a dataype is datatimeoffset for a column the filter will never work.
Upvotes: 0
Reputation: 1590
I have discovered a very interesting thing. The filtering on my grid was not working. The icon was there, but it was not clickable. And it all was acting weird. For example at sorting it was adding a long tail to the query string. And I spent two days on this. Until I found the problem. I had four tabs on a page, and in each I was loading a partial. Each partial was containing one grid. The first three grids (on the first three tabs) were working fine. The fourth was not. I have moved the last partial in the first tab, it was working fine, but the grid in the third tab was not working anymore. The problem was that only three grids on a page were working. If I had all the four grids on the first tab, only the first three were working, the fourth was not. Very weird. Didn't find the source of the problem though...
Upvotes: 0
Reputation: 363
if you are using Datakeys or if you have enabled custom binding on the grid action method, removing that might solve the problem.
Upvotes: 0
Reputation: 5892
In order to specify the size of the grid, you could wrap it in a div:
<div style="width:300px;">
@(Html.Telerik()...
</div>
Also, make sure you enable sorting/filtering in your grid:
.Sortable(sorting => sorting.Enabled(true))
.Filterable(filtering => filtering.Enabled(true))
If it still doesn't work, ensure that the script file being created by the Telerik script manager can be served by your web server (view source, grab the .axd link and paste it into your address bar).
One more thing:
Don't forget that the columns will expand to accomodate all their content so be sure your column widths match your parent div.
You could also use Firebug to examine any script issues in your page.
Upvotes: 1