问题
- Is it possible to have onclick in dojox.grid.datagrid's header.
I tried calling a function in header's onclick.. but it doesn't work.
<div class="claro" id="cvsd" name="dataGrid" onclick="getConnect('inner__cvsd');setWidgetproperty(this.id,'xy','inner__cvsd');" ondblclick="editCustomGrid(this.id)" onmouseup="setDocStyle(this.id)" style="height: 200px; left: 44px; position: absolute; top: 114px; width: 950px;"> <table class="claro" dojotype="dojox.grid.DataGrid" id="inner__cvsd" rowselector="10px" style="height: 180px; width: 400px;"> <thead> <tr> <th field="Column1" id="Column1_2" width="100px" onclick="getConnect();"> Column1 </th> </tr> </thead> </table> <input id="hidden__cvsd" name="dataGrid" style="display:none;" type="hidden">
回答1:
There's an event called onHeaderCellClick
which will probably do the job. If you need to get more information about events and such things I recommend reading the API Documentation.
I wrote an example JSFiddle (grid is created programmatically, but you can do that declarative too) which you can find here.
The code that I use to call the event is the following:
onHeaderCellClick: function() {
console.log("Header clicked");
},
But of course, you can change this with whatever you like.
来源:https://stackoverflow.com/questions/15893300/declarative-dojox-grid-datagrids-header-has-onclick-event