Telerik Experts, I need your help guys!
In my grid, data gets bound on the client, through .ClientEvents .OnDataBinding.
I just call grid.dataBind(customData). Data gets displayed, but grouping, filtering, sorting don't work. Is it possible to group or filter stuff after grid.dataBind call?
Right now it just moves my columns around and doesn't do any grouping. Sorting and filtering fails also.
Can you show me a simple example of grouping without any server calls please?
You may want to consider using the Operation Mode feature, which was released in the recent Q2 2011 release.
Client operation mode - This new mode allows operations like sorting,
paging, filtering or grouping to be performed purely on the client, by
making a single initial call to the server to retrieve all data.
Client Mode Implementation:
Html.Telerik().Grid(Model)
.Name("YourGrid")
.DataBinding(dataBinding => dataBinding
.Ajax()
.OperationMode(GridOperationMode.Client) // Set to Client
.Select("Select", "Home")
)
Otherwise, to manually group using javascript, as follows:
<script type='text/javascript'>
function yourGrid_onDataBinding(e){
//Grabs your Grid
var yourGrid = $("#yourGrid").data("tGrid");
//Removes any existing groupings
yourGrid.groups = [];
//Ensure the column you wish to group by is EXACTLY as it appears in the Grid
yourGrid.group("yourColumnName");
}
</script>
Here are a few useful threads from the Telerik MVC forum that might help you solve your issue if this isn't a viable solution for you:
Client-Side Grouping | Has a great deal of code for client-side grouping operations
Client-Side dataBinding | More client-side code, talks about ClientSideGroupHeaderTemplates
Grouping with OperationMode.Client | If you have any issues with OperationMode.Client
As I know you couldn't do it without any hit to the server again.
But you can do it by Ajax throw JavaScript.
All you need to do is and these methods will rebind your grid :
// For filtering
grid.filter("propName~eq~youValue");
// For grouping
grid.group("column Title");
And take care this is column title not property name so if your property is "CustomerName" and your column title is "Customer Name" the you should pass the column title.
Anyway this will make an Ajax call to the controller to rebind Grid again.
Update:
Your grid should set .EnableCustomBinding(true) and you should decorate controller method that get your Ajax grid with [GridAction(EnableCustomBinding = true)] Attribute.
Hope this helped
I'm doing the exact same thing in my grid. I'm using 2011.2.629, jQuery 1.6.2. I'm actually doing this for external filtering--so I don't use the built in filtering--but grouping and sorting both work for me.
We need some code, man.
As someone else mentioned, make sure you have the following set:
dataBinding.Ajax().OperationMode(GridOperationMode.Client)
Is your grid bound at runtime? If not, bind it to an empty viewModel that's the same as the one you're using in the dataBind(). Also, how are you binding to the new list? It could be something in your onDataBinding().
Related
I am moving to Blazor and attempting to work out how to use custom filtering in Radzen's DataGrid. Here is an example of what I am looking to do (from the old app I need to migrate):
As you can see, there is a filtering section above the grid. Of course I know that Radzen has built-in filtering in the grid itself, but that doesn't help when the filter you want to apply is to a column that is not visible on the grid..
So basically: how do you filter on columns that are not in the grid? I am using OData.. if there is a way I can modify the OData filter when the search button is clicked and reload the grid, that would be helpful.
Sorry if I misunderstood you. As you said, when search button clicked you can load data from the DB by using oData filter and reload the Radzen data grid.
then just call StateHasChanged();
I worked out a solution. You can see it here: https://forum.radzen.com/t/radzen-datagrid-custom-filtering/9448/12
Basically I copied their code from /Radzen.Blazor/QueryableExtension.cs and modified the ToODataFilterString() method to use a collection of FilterDescriptor instead of RadzenGridColumn<T>.. As the name implies, it returns an OData query string.. which I use to filter the grid's data. A working example, with full source code can be found here: https://github.com/gordon-matt/Extenso/tree/develop/Demos/Demo.Extenso.AspNetCore.Blazor.OData
I have a kendo grid with server side paging. On the same page, I also have a clear button which should clear the data of the grid and replace it with blank rows. Is it possible to clear the filters of that grid, without calling the server side read? Currently when I do this, $("#grid").data("kendoGrid").dataSource.filter({}), it will call the server side function and load the data. Anyone can point me to the right direction? Thanks.
Despite serverFiltering set to false by default, it seems that filter() automatically calls transport read every single time.
However, you can try this:
dataSource._filter = null;
This will cancel any filters applied to the dataSource without calling transport read. But, you have to be cautious with this approach as it isn't an "official" configuration documented by Telerik. The property _filter is internal, so to speak.
You can verify this works by console logging the requestEnd event and seeing that this doesn't make a request.
Can anybody suggest me the possibilities to differentiate the filtered Telerik grid column with other columns. Meaning that I can provide different color scheme to differentiate the filtered column.
Thanks
Speaking as someone who has had to deal with the Telerik MVC grid in a similar manner, I will share with you my solution for doing this:
1) Run the web page that has your grid, and view the source.
2) Find out, by viewing the source, what exactly happens when the filter is turned on (i.e. an attribute change, some function being called, etc.).
3) Using jQuery, set the color scheme of that column when that event occurs.
It's rather annoying that you can't just do it using Telerik's control itself, but this should help you out.
I have an application that is making extensive use of telerik controls and am looking for an example/demo of Telerik MVC grid that uses server binding to display the initial grid and then allow inline editing using ajax. I have a selection that is returning a lot of data and erroring out at the maxJsonLength. The code to configure the grid would be helpful and I should be able to fiigure out the rest. I think I saw an example somewhere of an ajax bound grid that used server binding for the initial load but I can't find it.
Having a server-side bound grid with ajax editing is possible. However you first need to solve the maxJsonLength problem. The grid needs to serialize the first page of data (which is initially displayed server-side) as JSON so it can be then edited on the client-side. It seems that you are serializing too much data which hits the maxJsonLength limit. I can think of two ways to deal with this:
Use a ViewModel and serialize only the properties which are bound to the grid. This will reduce the total JSON size.
Increase the maxJsonLength. This however is not easy as setting it from web.config does not work in ASP.NET MVC. You need to create a custom JsonResult object with its own JsonSerializer. This code library project shows how.
You have mentioned Telerik in your title but not in main question, so I assume that you are okay with other grid controls.
In that case you can try Jq grid, it's very flexible and easy to use. I have been using it for some time now and find it very useful.
For your particular case see below link
http://www.trirand.com/blog/jqgrid/jqgrid.html
I'm using the Telerik RadComboBox control. I have two related combos and when the user selects a value in the first one I filter the second one.
I use the code below to achieve this:
localeCombo = $find("<%= ddlLocale.ClientID %>");
localeCombo.requestItems(item.get_value(), false);
This works totally fine, but when I do a postback my filtered combo resets to the original non filtered list, although all other controls retain their state. I assume this is because the server side list of items is not being updated when I use the client side callback requestItems() function.
Is this the case? Is there a simple way around this?
Any help would be much appreciated!
Thanks
Chris
Yep, most probably your suggestion is true. You may try keeping the second filtered combo value in session or cache storage and then restore it from there on postback - at least this is what I would do.
This is a bug with RadComboBox. I opened a ticket.