English 中文(简体)
我如何把CSS的一个班子从一个支干 cell的囚房中删除?
原标题:How do I remove a CSS class from a jqGrid cell?
  • 时间:2011-06-14 15:47:03
  •  标签:
  • css
  • jqgrid

It is possible to add a CSS class to a jqGrid cell using the setCell method as below.

grid.setCell(rowId, "ColumnName", "", "my-style-class");

考虑到这一方法似乎只能够add CSS课程,如何从一个jqGrid囚室搬走一间CSS班?

最佳回答

可以用标准jqGrid方法取消电话。 因此,你必须手工操作:

var iCol = getColumnIndexByName(grid,"ColumnName"),
    tr = grid[0].rows.namedItem(rowid), // grid is defined as grid=$("#grid_id")
    td = tr.cells[iCol];
$(td).removeClass("my-style-class");

<代码>ColumnIndexByName是一种简单的功能,可按栏目索引:

var getColumnIndexByName = function(grid,columnName) {
    var cm = grid.jqGrid( getGridParam , colModel );
    for (var i=0,l=cm.length; i<l; i++) {
        if (cm[i].name===columnName) {
            return i; // return the index
        }
    }
    return -1;
}

See the demo here

<>UPDATED:Free jqGridiColByName 内部参数,可加以使用,而不是。 <代码>iColByName参数将在内部由自由支架填充,并将通过重整栏加以更新。 因此,安全使用

var p = grid.jqGrid("getGridParam"), // get the reference to all parameters
    iCol = p.iColByName["ColumnName"], // get index by column name
    cm = p.colModel[iCol]; // item of "ColumnName" column

方式非常简单,非常快。 应考虑这一特点列入免费的jqGrid<><>>/em>出版免费jqGrid 4.8。 因此,必须从Gite Hub下载最新消息,或至少使用4.9-beta1自由 j。

问题回答

一个人可以轻松地在牢房中增加新班级,将旧的班级删除如下:

$("#gridname").removeClass( oldclass )
              .setCell(rowId, column_name ,  , newclass );

Where rowId is id of the row containing corresponding cell and can be obtained as:

var ids = $("#gridname").jqGrid( getDataIDs );




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

Drop down background url in Safari Issue

selectBox.selectCSS { background: url(/Images/replacementSelectBackground.png) top left no-repeat height:auto; } I have an issue in Safari only where the image is not rendering on top ...

CSS specific for Safari

How do you target specifically safari in css with styles?

Aligning textarea in a form

Ive used the following css code to align my form elements: form { position:relative; } form input { position:absolute; left:11em; } However, the textarea element is not aligned correctly with the ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

CSS problem with page footer

I have defined my page footer in the css file as: #footer { position: absolute; height: 50px; text-align: center; background: #66CCCC; bottom: 0px; left: 0px; width: 100%; height: ...