在声明性的dojox.grid.datagrid的onresizecolumn中获取列索引 [英] Get column index in onresizecolumn of declarative dojox.grid.datagrid

查看:309
本文介绍了在声明性的dojox.grid.datagrid的onresizecolumn中获取列索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  • 在声明性的dojox.grid.datagrid中,我使用表标记中的onresizecumn列。


onresizecolumn =columnResize(this.id,this.cellIdx)

onresizecolumn="columnResize(this.id,this.cellIdx)"

onresizecolumn调用一个函数。在调整特定列的大小时,我想要获取cellIdx。

onresizecolumn calls a function. on resizing particular column i want to get the cellIdx.

<div class="claro" id="eterte" name="dataGrid" onclick="getConnect('inner__eterte');setWidgetproperty(this.id,'xy','inner__eterte');" ondblclick="editCustomGrid(this.id)" onmouseup="setDocStyle(this.id)" style="height:200px; left:39px; position:absolute; top:251px; width:950px;">
     <table class="claro" dojotype="dojox.grid.DataGrid" id="inner__eterte" onresizecolumn="columnResize(this.id,this.cellIdx)" rowselector="10px" style="height: 180px; width: 400px;">
          <thead>
               <tr>
                    <th field="Column1" id="Column1_6" width="159px">
                         Column1
                    </th>
               </tr>
          </thead>
     </table>
     <input id="hidden__eterte" name="dataGrid" style="display:none;" type="hidden">
</div>

function columnResize(id,index){
            alert();
            alert(id);
            alert(index);
        }


推荐答案

阅读 API文档我得出结论,Dojo 自动发送单元格事件处理程序的索引。所以解决方案是简单地提供以下属性 onResizeColumn =myFunction,然后定义一个这样的函数:

By reading the API documentation I come to the conclusion that Dojo automatically sends the Cell index to the event handler. So the solution is by simply providing the following attribute onResizeColumn="myFunction" and then you define a function like this:

function myFunction(cellDx) {
    alert(cellDx);
}

这应该工作,我甚至做了一个 JSFiddle 进行测试。顺便说一下,你有什么理由要以声明的方式做所有的事情吗?就我的经验而言,在JavaScript中编写大部分内容要容易得多。

This should work, I even made a JSFiddle to test it. By the way, is there any reason why you would like to do all of it in a declarative way? As far as my experience goes, it's a lot easier to write most of this in JavaScript.

这篇关于在声明性的dojox.grid.datagrid的onresizecolumn中获取列索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆