Kendo Grid sortable property case sensitive issue - kendo-ui

I have a kendo grid i need to sort my column data using sortable:true this property my data in three formats . while sorting it takes Upper case first and lower case letter second (like A B C a b c ....).
Any one knows the solution(I search this through many blogs but i can't)

Here's a solution which replaces the comparer used by the datasource:
https://gist.github.com/JohannesHoppe/4161255
And here's the relevant thread I got that link from (that's also where Sankar's solution is from): http://www.kendoui.com/forums/kendo-ui-web/grid/how-to-enable-case-insensitive-sorting-on-kendo-ui-grid.aspx
(note that case-insensitive sorting is apparently implemented in newer versions of Kendo UI, so you might just want to upgrade)

you can sort on DataSource. So you can add a hidden field to DataSource and make it to lower case. Sort this hidden field.
Here is an example:
userNamen = [];
$.each(obj.users, function(i, el){
userNamen.push({ no: el.no,
name: el.ID,
email: el.email,
fax: el.faxDirect,
phone: el.phoneDirect,
toLowerCase: el.ID.toLowerCase()
});
})
$("##callTo").data("kendoDropDownList").setDataSource(userNamen);
$("##callTo").data("kendoDropDownList").dataSource.sort({ field: "toLowerCase",
dir: "asc" });

Related

Kendo number formatting - without exponent

I have a column in grid with type of float and I would like to have numbers displayed without 'e'. Is that possilbe?
e.g.
I don't want -1e-7, but -0.0000001.
What format should I use for that column?
Found a solution. The problem is in Kendo DataSource, which automatically converts this kind of data. The solution is to have column template which would enforce formatting of value.
column.template = function(val) {
return kendo.toString(parseFloat(val[column.name]), '#.#######');
}

Kendo UI Grid sum aggregate on a column with an optional property

I'm using the Aggregates feature of a Kendo UI Grid Widget to display the sum of a grouped column. The column in question is bound to an optional field / property so when the data set includes a data item where property is not present (i.e. undefined), the sum ends up being NaN as you would expect.
The Kendo DataSource calculates these aggregates "when the data source populates with data" but does not include a feature to allow custom aggregates that would allow me to implement a version of sum that substitutes 0 for undefined values.
I can see where the sum aggregate function is defined in kendo.data.js but I would prefer not to change that if possible.
I have an idea how to solve this by writing a function to query the $("#myGridId").data("kendoGrid").dataSource but I'd like to know if there is a better option.
After comparing the latest code in kendo.data.js to my project version (2013.1.319) I see that they have changed the implementation of the sum aggregate function to handle this case by only performing the addition if the value is a number. Problem solved if I can get the project updated to the latest version of Kendo UI.
The code snippet below is at line 1369 of version 2014.1.416.
sum: function(accumulator, item, accessor) {
var value = accessor.get(item);
if (!isNumber(accumulator)) {
accumulator = value;
} else if (isNumber(value)) {
accumulator += value;
}
return accumulator;
}

jqGrid - Disable Reordering of Specific Columns

I have a jqGrid with the grid-level 'sortable' option enabled. This lets me drag columns around to reorder them, which is great. But I want to prevent users from doing this with one specific column, leaving the others unaffected. Is this possible?
I find your question very interesting and so I made the corresponding demo which demonstrate the solution. On the demo is the first column "Date" unsortable.
I recommend you to read two other old answers on the close subject: this and this. My suggesting are based on the same idea.
There are internal jqGrid method sortableColumns which will be used internally if one uses sortable: true option of jqGrid. The sortableColumns method uses jQuery Sortable for the implementation and initializes items options of the grid having id="list" to the value ">th:not(:has(#jqgh_list_cb,#jqgh_list_rn,#jqgh_list_subgrid),:hidden)". It makes the columns "cb", "rn" and "subgrid" unsortable. The columns could be inserted in the grid if you use jqGrid options multiselect: true, rownumbers: true or subGrid: true. In the same way is you have the column with name: "invdate" then the corresponding id of the column element will be jqgh_list_invdate. So one can use the option sortable as the following
sortable: {
options: {
items: ">th:not(:has(#jqgh_list_cb,#jqgh_list_invdate,#jqgh_list_rn,#jqgh_list_subgrid),:hidden)"
}
}
to make the "invdate" column unsortable.

Dojo DataGrid (EnhancedGrid) sorting issue

I have a DataGrid, created programmatically and loaded from ItemFileReadStore.
I want the first column of DataGrid always be sorted in descending order and disabled for user for sorting. Any other column should be available for sorting as a secondary sortable.
I don't want to give users such a powerful(complex and confusing) feature, as sorting by multiple columns, because there are too many columns in my grid.
So, it should be one sortable column for user and another one "already sorted unsortable" column in fact.
Does anyone know how can this be achieved?
Thanks.
To sort the first column add "sortInfo:-1" when you created your object.
To allow sorting the grid from any other columns but not the first you need to overwrite the function canSort.
To create you grid should now look like this .
dijit.grid.DataGrid({
canSort: function (sortInfo) {
if (Math.abs(sortInfo) == 1){
return false;
} else {
return this.inherited("canSort", arguments);
}
},
sortInfo: -1, .....
If you need to sort on more as one column you need dojox.grid.enhanced.plugins.NestedSorting.
http://dojotoolkit.org/reference-guide/1.7/dojox/grid/EnhancedGrid/plugins/NestedSorting.html

Telerik MVC Grid groups with key, display, and sort values?

I'm running a grid with Ajax binding with added groups:
.Groupable(grouping => grouping
.Groups(groups =>
{
for (int i = 0; i < TagGroups.Count; i++)
{
groups.Add(c => c.Tags[i].Name);
}
})
)
This is grouping the data by the Name property. In essence, the Name property is being used for three jobs. It is acting as the group key, it is the displaying value, and is used to sort the groups alphabetically.
I want to specify the property for each of these jobs. I want the Id property to act as the group key, the Name property to act as the display value, and the Order property to act as the sort value numerically instead of alphabetically.
If this is a tall order, I can live with the Name property as the group key and display value, but I need to specify the Order property as the sort value. Any thoughts? I'd prefer not tinkering with back-end data with Linq or such, because It makes a lot of sense to just configure a Telerik Grid to do this.
Both Name & Order are bound columns in the grid. Use only Order in the Groupable list. Then in your grid DataBound(), replace each order with the corresponding Name property.

Resources