jqGrid - Disable Reordering of Specific Columns - jqgrid

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.

Related

Is it possible to add custome condition in filters?

I want to add greater then and lessthen condition in below example. is it possible?
Be careful about the option columns of your Handsontable definition.
The option Filters already have conditions 'Greater than' & 'Lesser than' but they will be available only for 'numeric' data type.
If I take this example, regardless of the data type, the conditions won't be available.
Now if I add the columns option in this edited example :
columns: [
{type: 'text'},
{type: 'numeric'},
],
The conditions you need will became available for the 2nd column.
Check Filter By Condition in dropdown
Fiddle Link :
http://jsfiddle.net/kumarrishikesh12/wr7snuws/

Kendo Grid sortable property case sensitive issue

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" });

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

Sorting enable for a limited number of columns

In a grid with 5 columns, I would like to have the possibility of sorting only for columns 2 and 4.
What is the correct demarch for implement this ?
- declare sortable to true for columns 2 and 4
- what else ?
Default value of sortable property is already true (see here). So you have to include
sortable: false
property in the definition of all columns in colModel with exception columns 2 and 4. If you have many columns, then it would be better to change defaults for colModel items:
cmTemplate: { sortable: false }
After that you should include sortable: true in columns 2 and 4. In the way you can change any other defaults for colModel. See the answer for more details.

jqgrid, setting value of an editable select control

I have an editable grid, with one of its column is a SELECT type, e.g.
colModel:[{ name:'myText',index:'myTextColumn',editable: true, edittype: 'text'},
{name:'myList',index:'myList', width:editable: true,edittype: "select",
editoptions: { value: {'v1':'Value 1','v2':'Value 2',....} },
............
]
I use the method setRowData to set data in one of the rows by code. The value that I pass for the Select type cell is the option value, e.g.
jQuery("#myGrid").setRowData( rowId, { myText:"Text 2", myList:"v2", ..... })
After executing this code, the text type cell displays "Text 2", as expected. However, the the Select type cell displays "v2" not "Value 2". Only when I click that cell the display changes to "Value 2"
How can I force the select type cell display the correct value without the need for manual click later?
Meanwhile I found the solution for this problem. Just add a formatter of type "select" to the column.
http://www.secondpersonplural.ca/jqgriddocs/_2kn0mlo1p.htm

Resources