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

[Solved] Filtering grid on client side

5 Answers 103 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.
Murali
Top achievements
Rank 1
Murali asked on 21 Jun 2011, 02:03 PM
I am trying to filter a grid on client side using client side API.

The code is as follows:

<

 

 

script type="text/javascript" src="/Scripts/2011.1.328/telerik.grid.filtering.min.js"></script>

 

<

 

 

script type="text/javascript">

 

 

 

function OnLoad(e) {

 

 

 

var grid = $('#MyStaticListsGrid').data('tGrid');

 

 

 

//Display all records whose Name property is equal to Only Tom

 

grid.filter(

 

'Name~eq~Murali');

 

 

}

 

 

</script>

 

 

@model

 

IOrderedEnumerable<CdcSoftware.Pivotal.ThinClient.Common.ViewBag.MetaqueryViewModel>

 

 

 

 

@(Html.Telerik().Grid(Model)

.Name(

 

"MyStaticListsGrid")

 

.ClientEvents(e => e.OnLoad(

 

"OnLoad"))

 

 

.Columns(columns =>

{

columns.Bound(o => o.Name).Width(120).Template(

@<text>

@Html.Hidden(

 

"Permission", @item.Permission)

 

@item.Name

</text>).Title(

 

"Static List Name").Filterable(true);

 

 

 

if (ViewData["AllSearches"].ToString() != "false") columns.Bound(o => o.ListType);

 

})

.DataBinding(dataBinding => dataBinding.Ajax().Select(

 

"_CustomBinding",

 

 

 

"Metaquery"))

 

.HtmlAttributes(

 

new { style = "text-align:left" })

 

 

.Sortable(sorting => sorting

.SortMode(

 

GridSortMode.SingleColumn))

 

.Scrollable(scroll => scroll.Height(

 

"385px"))

 

 

 

)

 

Registering of the required javascript files is done is _layout.cshtml.
Whennever i run this i get a javascript error "object does not support this property".
Can you please let me know what the issue is

Regards,
Murali

5 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 21 Jun 2011, 04:21 PM
Hi Murali,

 Unfortunately it is not clear what may be causing this problem as your code looks correct. Can you check with the JavaScript debugger to see which object does not have a property? The other option is to try and isolate the JavaScript error in a sample project which we can troubleshoot.

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Murali
Top achievements
Rank 1
answered on 23 Jun 2011, 07:50 AM
Hi Atanas,
I checked in the javascript debugger and the grid.filter function is failing.
Pls see the screen shot attached:
Pls investigate let me know what could be the issue
Regards,
Murali
0
Atanas Korchev
Telerik team
answered on 23 Jun 2011, 07:56 AM
Hi Murali,

 Make sure the telerik.grid.filtering.min.js file is included. It defines the filter function.

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Murali
Top achievements
Rank 1
answered on 23 Jun 2011, 08:10 AM
Hi Atanas,
This file is included. I also tried manual registration of javascript files but still getting the same error.
Regards,
Murali
0
Dimo
Telerik team
answered on 23 Jun 2011, 09:18 AM
Hi Murali,

You can try using

var grid = $(this).data('tGrid');

instead of

var grid = $('#MyStaticListsGrid').data('tGrid');

If this fixes the problem, it means that the ID in the Javascript code does not match the client ID of the Grid.

Alternatively, you can check whether the following returns a jQuery object with one DOM element inside:

$('#MyStaticListsGrid')

If none of the above helps in resolving the issue and you are sure that all required Javascript files are registered, we will need a standalone runnable demo to investigate further.


Kind regards,
Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Murali
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Murali
Top achievements
Rank 1
Dimo
Telerik team
Share this question
or