Setting class attribute in jqGrid searchoptions - jqgrid

I am in the process of upgrading from jqGrid 4.5.2 to 5.5.5. When contructing the colModel searchoptions were set as follows:
searchoptions: {
sopt: ["eq", "cn", "bw"],
value: partyStr,
attr: { class: "grid-select2 grid-dd-autosize" }
}
As of 5.5.5 the class attributes are no longer being added. Looking at the documentation here the attr option doesn't seem to exist anymore.
Is there a way to add a custom class to the search object on the filterToolbar with version 5.5.5.

This is not a way to set attribute when use searchoptions or editoptions.
The way is the same for the both.
To do what you want you need to add the attribute key in searchoptions object and not specify the attr property. To work this set it this way.
searchoptions: {
sopt: ["eq", "cn", "bw"],
value: partyStr,
class: "grid-select2 grid-dd-autosize"
}
P.S. Thanks for point us for the docs. We have updated the documentation and now you can see the right way to do this. Use the same link and clear your browser cache to see the update

Related

"Cannot call method 'getColumns' of undefined " on FiltersFeature of LiveSearchGridPanel ExtJS

im getting the Uncaught TypeError: Cannot call method 'getColumns' of undefined when clicking on the header toolbar of a Live Serach Grid Panel on ExtJS. Im implementing filters with the Filters Feature.
Heres some of my code:
Ext.require([
'Ext.grid.*',
'Ext.ux.grid.FiltersFeature',
'Ext.ux.LiveSearchGridPanel'
...
]);
var filters = {
ftype: 'filters',
encode: false,
local: true
};
var grid = new Ext.create('Ext.ux.LiveSearchGridPanel', {
selType: 'cellmodel',
store: store,
columns:[
{
header: "Evento",
width: 90,
sortable: true,
filterable: true,
dataIndex: 'RH_DESCRIPCION',
filter: {
type: 'string'
}
}],
features: [filters]
...
This is the block of code where the exception occurs:
Ext.Array.each(grid.columnManager.getColumns(), function (column) {
//Uncaught TypeError: Cannot call method 'getColumns' of undefined
if (column.filterable === false) {
filters.removeAtKey(column.dataIndex);
} else {
add(column.dataIndex, column.filter, column.filterable);
}
});
Any help will be appriciated!
After doing heavier debugging it seems that grid.columnManager isn't very well supported on version 4.2. For any others with the same issue you should use:
grid.down('headercontainer').getGridColumns();
or
grid.down('headercontainer').getVisibleGridColumns();
to get a hold of columns on your grid. I believe this won't work with grouped columns, I've not tested it though.
Ext.Array.each(grid.columnManager.getColumns(), function (column) ...
change to
Ext.Array.each(grid.columns, function (column) {
it works well :)
grid.columns is not a supported/public property. It might not contain, for example, columns added with reconfigure. It will contain them if you use 4.2.0, but not in 4.2.1/4.2.2. This will happen even if you add Ext.selection.CheckboxModel, the checkbox column will not be included there in 4.2.2 and you will end up with "index mismatch" if you get the index from, lets say cellClick event.
Unfortunately, grid.columnManager or grid.getColumnManager() is new in 4.2.1/4.2.2 and it is a private property/method. Shortly speaking, either of those might stop working with next releases of ExtJS, and "columns" property is not reliable in all cases.
See some discussion here:
http://www.sencha.com/forum/showthread.php?277525
I haven't found any officially supported solution yet. I can't add comments, so I had to publish this as a full answer, thanks S.O.!
As others already posted, you should not use the columnManager property. Check Sencha's note about it:
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.grid.ColumnManager
This is a private utility class for internal use by the framework.
Don't rely on its existence.
I think the best option is to use this for all columns:
grid.headerCt.getGridColumns()
And this if you only need the visible columns:
grid.headerCt.getVisibleGridColumns()

Does jqGrid Able to Make Search Boolean Like 'This Picture'?

I want to implement multiple search with boolean data.
Does jqGrid able to make search with dropdown?
In mysql table, value for accredited field is boolean (0/1).
I am showing boolean value in presentation table is "not accredited or accredited".
And I want to search through this value. So, as picture shown above, we can pick dropdown which accredited or not accredited instead of type 0 or 1.
What you need to do is just usage of stype: "select" property in definition of accredited column in colModel and definition of searchoptions which corresponds you data. For example
stype: "select",
searchoptions: { sopt: ["eq", "ne"], value: "0:not accredited;1:accredited" }

Set search options for columns in MvcJqGrid

I can't find a way to set search options for a column? It seem they are set by default and there's no way I can change it.
We have this option in Jqgrid:
{ name: "outputid", index: "outputid", width: 30, searchoptions: { sopt: ['eq']} }
When doing this in MvcJqGrid:
.AddColumn(new Column("promoDate").SetAlign(MvcJqGrid.Enums.Align.Center).SetLabel("Fecha Ingreso").SetSearchType(Searchtype.Datepicker).SetSearchDateFormat("yy-mm-dd"))
I receive a 'bw' as rule op, not 'eq' as I would like to set.
Thanks!
I've updated MvcJqGrid (nuget package is also updated). As of now you can set a searchoption per column with 'SetSearchOption'. Your example would look something like this:
.AddColumn(new Column("promoDate")
.SetAlign(MvcJqGrid.Enums.Align.Center)
.SetLabel("Fecha Ingreso")
.SetSearchType(Searchtype.Datepicker)
.SetSearchDateFormat("yy-mm-dd")
.SetSearchOption(SearchOptions.Equal))
Let me know if this works for you.
First of all I should mention that I don't use MvcJqGrid myself. It's really important to set different sopt option for different columns especially if one uses toolbar searching. It seems that MvcJqGrid don't provide you enough possibilities to do this. Nevertheless it looks so that MvcJqGrid generate some JavaScript code for you. So if you can't generate exactly the code which you need then you can still change some properties of grid later. For example
$("#grid").jqGrid("setColProp", "outputid", { searchoptions: { sopt: ['eq']} });
change the properties of "outputid" column. It is important to make the changes before searching toolbar are created (before method filterToolbar) will be called. If you can't inject your JavaScript code before creating searching toolbar you can recreate it later with modified properties using destroyFilterToolbar method (see the answer and the pull request):
$("#grid").jqGrid("destroyFilterToolbar");
$("#grid").jqGrid("filterToolbar", { stringResult: true, defaultSearch: "cn" });

Kendo Custom tooltip for chart, returns tooltip's showing as Undefined

When using the event which allows us to custom the tooltips for a bar\line chart. The DataItem that is passed to the event is returned as Undefined . So, is there is property which I can be set that allows custom the tooltip, even when their is alot of pionts in a small area.
Example: template: "#= dataItem.employeeName #"
Any help would be appreciated.
I think you are looking for the tooltip.template option:
$("#chart").kendoChart({
tooltip: {
visible: true,
template: "#=employeeName#"
}
});
You shouldn't need to specify dataItem before the field name. Also, try checking data instead of dataItem.
Try this One:
tooltip: {
visible: true,
template: "#= dataItem.title #: #= dataItem.percentage #%"
}
For me it is working perfect.
Let me know if any issue.

JqGrid filter toolbar not refreshing on reload of grid

OK, I am having an issue with the filter toolbar retaining the filter values after clicking on the Refresh button at the bottom of the grid.
I have looked at numerous examples that do exactly that, clear the top filter toolbar fields to the default state (in the case of select list, to the first item in the list "Select..."), but I do not see any obvious difference between that code and mine
Values are being loaded into the filter toolbar drop down boxes via JSON request, and on selecting an item in the list the grid filters to the appropriate data.
The only thing that is not working is that the filter drop-down(s) do not clear the selected item upon clicking refresh grid.
Any ideas?
Not sure what code would help to post at this point, so I will post upon request
Justin
Well, I have answered my own question :)
The issue turned out to be related to naming convention for column names and indexes.
Example:
Before fix:
{ name: ClientId', index: 'ClientOrganization.Client.ClientId', width: '125', stype: 'select', searchoptions: { sopt: ['eq'], dataUrl: '#Url.Action("GetClientListForFilter")'} },
After fix:
{ name: 'ClientOrganization.Client.ClientId', index: 'ClientOrganization.Client.ClientId', width: '125', stype: 'select', searchoptions: { sopt: ['eq'], dataUrl: '#Url.Action("GetClientListForFilter")'} },
Basically the name needed to be the same as the index to properly refresh. Not sure if this is expected behavior or not, but the fix works. ;)
Justin

Resources