Kendo grid group header customize to show the value and more - kendo-ui

I have a Kendo grid that is groupable. The initial display needs to show all data items with no groupings displayed, i.e no 'group' and 'groupHeaderTemplate' are defined.
The grid contains a column (Suspension) where the value displayed is a translated dataitem value, i.e. if value > 10, display '*'.
When the user drags the Suspension column header cell to group, how can you customize the group header to show the value that it is grouping on plus the display 'value', i.e. 10-* ?

Do you mean on the button to turn off the group, or the group header text above each group in the grid ?
If the button to remove the grouping, I think you are stuck doing that manually.
If you mean the text above each group, columns have a groupHeaderTemplate property you can set.
groupHeaderTemplate: "Grouped By Name: #= value #"
See sample http://jsbin.com/IbITaT/2/edit

Related

Kendo UI Grid Edit popup's change update method return values

the normal way in kendo ui grid update data is add a edit popup.
What I want is, Think I change a value in text field.In update I added switch case and change the submit value. Then It will add that value and return that values to the grid. But I want to do is when get the return value and change it and show a different value in the grid.
Here is a example.....
In edit popup it has a input text field. I submit a value as "A". In the update I add a switch tells that If the value is "A" change the submit value to 1(number one).
Then it submit the value and show the value in grid as "1" not as the "A".
How I do this ???
I think you want a custom handler. In the grid you toss in this:
edit: function(e) {onEdit(e)},
and then on top of the page you do whatever logic you want to do
function onEdit(e) {
if (true) {
$("#Whatever").text('Hello') //Whatever in this case is a field in grid

jqGrid dynamic columns

I use jqGrid v4.4.5 and I want to create it with dynamic columns.
It is filled by "jqGridHandler.ashx" file .
I want send all information(column name,data,...) by JSON .
I search for it in Google but can not find a good answer.
By Click on each node(child) change whole grid(actions and columns...).For example by click on node3 the grid has three columns 'A' and 'B' and 'actions' but by click on node2 grid has columns 'C' and 'D' and 'actions'.
One can use jqGrid to create many different grids, tree grids, subgrids and so on. It's very important to understand whether you want to display grid with 10 rows or with 100000 rows. If you have 100000 rows (or some other large number of rows) you will have to implement server side paging and sorting of data. So if the user would click on the "next page" button the next rows should be loaded from the server. Why you would need to send all colModel data on paging or sorting? So you should clear understand that in server side scenario one need create all structures of grid only once and then one need refresh only the body of grid. So it would be bad choice to send all information (column name, column model, data,... at once).
Only if you have some hundreds or some thousand of rows in the grid and you can use loadonce: true option them you can load once all information (column name, column model, data, ...) per separate jQuery.ajax call and then create jqGrid with datatype: "local" and using data parameter which contains all grid data.
UPDATED: If you need change
// in the example below the grid with id="list" will be created
// with column having name: "c4" in colModel
var $grid = $("#list"), columnName = "c4";
...
var $colHeader = $("#jqgh_" + $.jgrid.jqID($grid[0].id) + "_" + $.jgrid.jqID(columnName)),
$sortingIcons = $colHeader.find(">span.s-ico");
// change the text displayed in the column
$taxHeader.text("New header text");
// append sorting icons to the new text
$taxHeader.append($sortingIcons);
Before your initialize the jqGrid you will need to have the information for your colNames and colModel properties of the jqGrid.
So in short, you will request the information from your server, once you have successfully retrieved that information you can then build the jqGrid and then the jqGrid can go and fetch it's data.
The following post has some example code on the client side:
jqGrid and dynamic column binding

Multiselect in jqGrid

I am using a JQGrid, and have designed the grid such that the first column is a checkbox. I am using the property of multiselect:true, and I am not writing any code other than this to get the checkboxes. How do I fetch the values from the rows where the checkboxes are checked?
To get the selected rows, use:
var selected = $("#tableid").jqGrid('getGridParam', 'selarrrow');
selected will be set to an array of IDs of the selected rows.
To get column values from the rows, use the getCell method. See How to get the selected row id in javascript?

jqgrid - change column header name automatically according to the width

in my site , i have a jqgrid table.
by default, the names of the columns (header) is longer than the width for column, because that i set the name with an ellipsis.
however, when resizing the column, the short name with ellipsis stays.
how can i get it work automatic ,
like the ellipsis should disappear and change to the full name when there is enough space, when the user is expanding the column.
thanks
You can add an event handler after the resizing finishes to reset the names. How are you storing / changing the names? If they're in an array, you can add a function like:
var columnNames = ['first', 'second', 'third'];
$("#mygrid").jqGrid({
...
resizeStop: function(newwidth, index){
jQuery("#mygrid").jqGrid('setLabel',index,columnNames[index]);
},
...
});

is there any column click event in ext js?

I am using Ext.grid.gridpanel.As in rowclick event, we can handle row click of grid..Is there any event to handle column click of grid?
i want to select a particular column of grid.
There is no special columnclick event on the gridpanel or the selection model, but you can listen to the
cellclick : ( Grid this, Number rowIndex, Number columnIndex, Ext.EventObject e )
event on the gridpanel itself - irrespective which selection model you use. Looking at the columnIndex you'll know which column has been clicked. If you want to react on clicks onto the header row, use the headerclick event instead.

Resources