Reputation: 1786
I'm using jqgrid to create grid. This one has 'main' one with headings and datas in it etc and 'advance search'. Unfortunately both of them are using same getColModel, and I want to have different heading and colname in advance search. For example I have something like this
getColModel: ->
[
{name:'dispId', label: i18n('ProjectList.dispId'), classes:'grid_col', width:6, searchoptions:{sopt:filterOperators.string}, formatter: ((cellvalue, options, rowObject) -> "<a href=\"#{url("/project/#{options.rowId}/view")}\">#{cellvalue}</a>")}
]
and i18n('ProjectList.disp') displayes both in column and in column name in advance search. My English is really bad, but I hope you understand what I want to do - I want to have different headings in main grid and advance search option, and I would not like to change anything in jqgrid sources only in my own *.js scripts. (maybe some attribute in colModel? couldn't find a think and i was searching for solution alot)\
advance search option I called 'pager' I believe
I added this to my initgrid
afterRedraw: ->
$("#{gridId} select").find("option[value='expectedRealizationDate']").html(i18n('ProjectList.expectedRealizationDate'))
$("#{gridId} select").find("option[value='closing']").html(i18n('ProjectList.closing'))
it works but only when I open advance search, when I add new filter label names go blind again
Upvotes: 1
Views: 955
Reputation: 1786
If someone would wonder how to do it heres an answer
$(@gridId).jqGrid('navGrid',@pagerId, {}, {}, {}, {}, {
afterRedraw: function() {
$("select").find("option[value='expectedRealizationDate']")
.html(i18n('ProjectList.expectedRealizationDate'));
$("select").find("option[value='closing']")
.html(i18n('ProjectList.closing'));
}
} );
Upvotes: 1
Reputation: 134167
The jqGrid code in grid.filter.js
explicitly uses the colModel name
and label
to generate the options in the dropdown:
str += "<option value='"+that.p.columns[i].name+"'" +selected+">"+that.p.columns[i].label+"</option>";
So you are not going to be able to achieve what you want using the jqGrid API, unless modifications are made to jqGrid itself.
That said, without modifying jqGrid you might be able to hack around and use the afterRedraw
function to replace the labels with custom ones. The code won't be pretty, but you might be able to get it working...
Upvotes: 1