jquery - Why does this technique not work to enable my "editable:true" column to sort properly? -
question: how enable "editable:true" column sort properly?
the following link seemed provide "onclick" handler function allow editable columns sorted. (https://stackoverflow.com/a/9290716/652078)
but, when using it, receive following error when click on column:
'handler' null or not object
message when click on column
below, i've provided column definition , "click" handler code borrowed above link.
-is there out-of-date regarding solution prevent working?
-or, column definition preclude such "onclick" handler working?
thanks help!
here column definition:
{ name: 'rectype', label: 'rectype', index: 'rectype', width: 100, fixed: true, keys: true, editable: true, edittype: "select", editoptions: {value: rectypelist}, stype: 'select', formatter: 'select' },
the click event function (technique described in above link)...
$(".ui-jqgrid-htable th").click(function() //.on('click', 'th', function(e) // { var $grid = contentb1grid; $.each($grid[0].grid.headers, function () { var $th = $(this.el), i, l, clickhandler, clickhandlers = [], currenthandlers = $._data($th[0], "events"), //$th.data('events'), clickbinding = currenthandlers.click; if ($.isarray(clickbinding)) { (i = 0, l = clickbinding.length; < l; i++) { clickhandler = clickbinding[i].handler; clickhandlers.push(clickhandler); $th.unbind('click', clickhandler); } } $th.click(function () { var p = $grid[0].p, savedrow = p.savedrow, j, len = savedrow.length; if (len > 0) { // there rows in cell editing or inline editing if (p.celledit) { // savedrow has form {id:irow, ic:icol, name:nm, v:value} // can call restorecell or savecell //$grid.jqgrid("restorecell", savedrow[0].id, savedrow[0].ic); $grid.jqgrid("savecell", savedrow[0].id, savedrow[0].ic); } else { // inline editing (j = len - 1; j >= 0; j--) { // call restorerow or saverow //$grid.jqgrid("restorerow", savedrow[j].id); $grid.jqgrid("saverow", savedrow[j].id); } } } }); l = clickhandlers.length; if (l > 0) { (i = 0; < l; i++) { $th.bind('click', clickhandlers[i]); } } }); });
my editable column sorting "correctly"...
recall column sorted editable "dropdown" (or listbox) column.
i jumping thru hoops - based on various posts regarding inability sort on "editable" columns. included try @ using snippet 1 of oleg's posted answers addressing such issue.
but, turns out, real problem sorting performed upon string value of dropdown list "key" value, rather display "value". (fwiw, "key" happens numeric code).
--so, again, $(".ui-jqgrid-htable th").click(function()
trying irrelevant actual problem. (although, still don't know why getting "handler null or not object" javascript error)
and, so, answers question to "why technique not work enable “editable:true” column sort properly?".
now, need research question : how configure editable listbox column - sorting performed upon "display" value, rather "key" value?
update: solved issue (answered own question, again) in how can configure jqgrid column definition sort performed on listbox entry's "display" value, rather "key" value?
--in case, thank took time @ least view earlier posted question.
:-)
Comments
Post a Comment