We are facing filter issue on Kendo Grid when filter value is mapped to 0, below is the piece of code.
(We are applying existing filters to the new datasource to get the expected result)
Code:
BulkTaggingDataSource.read().then(function () {
var filter = {};
if ($("#FoodGrid").data("kendoGrid").dataSource.filter()) {
filter.filter = $("#FoodGrid").data("kendoGrid").dataSource.filter();
}
var query = kendo.data.Query.process(BulkTaggingDataSource.read.data(), filter);
$.each(query.data, function (index, content) {
$.each(query.data, function (index, content) {
if ($.inArray(content.id, checkedIds) < 0) {
checkedIds[content.id] = state;
}
})
})
});
Filter which we get from $("#FoodGrid").data("kendoGrid").dataSource.filter(): is
In our case if the {field: 'TotalHours', operator: 'eq', value: '0'} if the filter value is '0'
we get the query.data as empty array and we wont get the expected result.
and filter will work if the {field: 'TotalHours', operator: 'eq', value: '5'}
we are facing issue only for '0' filter. and in schema we have declared 'TotalHours' as number.
Kindly let us know how to fix this issue.
$("#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.
In Kendogrid how do we change the default filter options from "is true" and "is false" to "Yes" and "No" to match the data in the columns
Hello, i have a gantt which i am working on. This data is organised with multiple levels, sometimes up to 7. We have discovered that when filtering, this works for items up until the second level, but on items underneath the second level, the filtering doesn't seem to be picking up any thing. For instance if we have the following structure (sorry for the simplicity)
Test 1
- Test 2
-- Test 3
---- Test 4
If we try and filter on "Test 1" or "Test 2" then the results will display those rows, but if we try "Test 3" it doesn't return anything. Is there a limit on filtering on a hierarchy in this way?
I faced an issue related to decimal filters.
the issue was "when I enter filer value "6167.1" which actually appears in a grid cell, no result is filtered out so while debugging I found that when data-source is provided to grid that value is actually 6167.07 and kendo jquery UI renders it 6167.1 in the grid. So when I enter filter value "6167.07" it works and in grid value still appears/ shows 6167.1"
According to my understanding filter is working fine on the data source but while rendering it rounds up the data and shows a different value to the client due to which filter errors are reported.
So I need help, please share the code snippet to turn off JS data rounding up used in this kendo library/plugin
According to here: https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/configuration/columns.filterable.ui
You can (for example) replace a filter input with a textarea, however, the example as shown doesn't work because it's not bound to the filter value.
It will work if you add the data-bind attribute:
$(element).replaceWith("<textarea data-bind='value:filters[0].value'></textarea>");
Now the filter value actually gets passed to the server and populated when you call setOptions on the grid.
As there is no easy way to provide your own filter template, I'm trying to create a complex filter (a checkbox list for a flags enum) using replaceWith.
I have some checkboxes and use some JavaScript to set the value of an input that is bound using the data-bind attribute.
This all works fine and the filter value is passed to the backend as expected, and the input value is populated via setOptions when I reload.
For example:
$("#grid").kendoGrid({
columns: [ {
field: "flags",
filterable: {
ui: "testFilter"
}
} ],
filterable: true,
//...
});
function testFilter(e) {
$(e).replaceWith(`
<input type='checkbox' value='1' onclick='setFilterInput(this);' />
<input type='checkbox' value='2' onclick='setFilterInput(this);' />
<input type='checkbox' value='4' onclick='setFilterInput(this);' />
<input type='checkbox' value='8' onclick='setFilterInput(this);' />
<input id='filterInput' type='text' data-bind='value:filters[0].value' />
`);
}
function setFilterInput(e) {
var x = $(e).val();
var c = $(e).is(":checked");
var input = $("#filterInput");
var val = parseInt(input.val(), 10);
if (val === NaN) {
val = 0;
}
input.val(c ? val | x : val ^ x);
input.trigger("change");
}
The problem is that I need to know the current filter value when the testFilter function is called, so I can check the correct checkboxes when the grid is loaded. For example, this shows an empty value, even when the filter is already set:
function testFilter(e) {
console.log("the current filter value is", $(e).val());
}
I can't get the value of the filter input because it's bound after the testFilter function is called.
How can I access filters[0].value from inside the testFilter UI function?
Preferably without having to go top-down via $("#grid").data("kendoGrid") etc.
I am trying to implement filter which can support relative fields i.e. the first field would be table names once user choose any table then second field gets populated with all columns available for selected table. Now users can choose operator and pass value for filtering the column value. So basically I want to filter on basis of column's value. As I dont want to put all columns for all tables in one field because that makes my drop down very long as I have huge columns in some table and also user wont be able to search specific column easily hence I want to introduce one more field which is table drop down. Once user select from table drop down then column dropdown will only have selected table column which reduce the columns number and user can choose easily. see the attached screenshot for same. So the expression preview should be something like <field1-N>.<field2-N> <operator> <value> e.g. "table1.column5 is equal to myvalue". How we can achieve this ? I tried using editortemplate of field property of kendo Filter widget and added field 2 as shown in attached screen shot but after that not able to get field 2 value in expression. Can someone suggest what are the other ways we can achieve this ?
Which event can I hook into in order to run custom code before a KendoGrid FilterMenu opens every time?
There is an event that runs once before it opens (filterMenuInit) and an event that runs every time after the menu opens (filterMenuOpen), but I need the third kind, which runs every time before opening.