【问题标题】:how to delete the contents of a particular column of jqgrid table?如何删除jqgrid表的特定列的内容?
【发布时间】:2012-03-09 16:15:08
【问题描述】:

如何删除jqgrid表的所有行的特定列的内容?

或者我如何在一个单一的镜头中设置具有特定值的 jqgrid 表的所有行的特定列。

【问题讨论】:

    标签: javascript jquery jqgrid


    【解决方案1】:

    你可以这样做:

    删除内容:

    $('td[aria-describedby=<your table name>_<column name>]').html('');
    

    设置一个值:

    $('td[aria-describedby=<your table name>_<column name>]').html('whatever');
    

    【讨论】:

    • 对不起,我问的问题很准确。我听不懂
    • table name = "tab", column name='col1' 但是 aria- describeby 呢?我的理解是你的代码正在形成一个 id,但是 '=' 是如何出现在 id 下的
    • 你需要勾选jQuery's documentation,即选择具有指定值的属性的元素,td是选择td元素,aria- describeby是jqgrid自动分配的属性,其值在你的情况下是“tab_col1”,所以选择器是$('td[aria-describedby=&lt;tab_col1&gt;_&lt;column name&gt;]')(所以在这种情况下你不需要id)
    • 太好了,我很高兴,如果这是您期望的答案,如果您将其设置为接受的答案会很好......
    • 我不想在答案被接受之前写我的 cmets。更有效一点是 1) 像描述的那样获取列的索引 here 2) 使用 $("#grid").find("&gt;tbody&gt;tr.jqgrow&gt;td:nth-child("+(pos+1)+")").empty() 其中 pos 是由 getColumnIndexByName 返回的基于 0 的列索引。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-30
    • 2022-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多