[CLOSED] how to add a css class to a cell of gridpanel?

  1. #1

    [CLOSED] how to add a css class to a cell of gridpanel?

    I want to show a gridpanel , when a cell of gridpanel is empty or null , the cell's border color is red.
    i try to use render for the column
       <ext:GridPanel runat="server" ID="gdHouseCenter"  Title="XXX"  ForceFit="True"  >
    ...
     <ext:Column runat="server" DataIndex="Unit" Text="所属单元"   CellCls=""    >
                                                 <Renderer Fn="emptyShow"></Renderer>
                                                 <Editor>
                                                     <ext:TextField runat="server"></ext:TextField>
                                                 </Editor>
                                             </ext:Column>
      var emptyShow =  function(value,metadata,record,rowIndex,colIndex,store,view) { 
                if (value === null) {
                    var dataIndex = App.gdHouseCenter.colModel.getDataIndex(colIndex);// here is error , how to correct it?
                     var color = record.data.colors[dataIndex];
                     color.colorCls = 'empcls';  //here set a class for the cell , is it right?
                }
                return value;
            }
    Last edited by Daniil; Jun 08, 2015 at 10:11 AM. Reason: [CLOSED]
  2. #2
    Hi hdsoso

    You were on the right track. Update your emptyShow function to this

    var emptyShow = function (cellValue, metadata, record, rowIndex, colIndex, store, view) {
        if (cellValue == "")
            metadata.tdCls = "x-grid-cell-custom";
    
        return cellValue;
    }
    You could remove the unwanted parameters if there is no need for them.

    Also, the following css class

    .x-grid-cell-custom {
        border-color: red red red red !important;
        border-width: 1px 1px 1px 1px !important;
    }

Similar Threads

  1. Replies: 3
    Last Post: Feb 20, 2014, 4:24 AM
  2. [CLOSED] Gridpanel editalbe cell - select all text of field on cell click
    By PriceRightHTML5team in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 18, 2013, 5:20 AM
  3. Replies: 7
    Last Post: Dec 10, 2012, 1:33 PM
  4. [CLOSED] Gridpanel cell dropdown menu to the right of cell
    By RCM in forum 2.x Legacy Premium Help
    Replies: 9
    Last Post: Nov 23, 2012, 4:01 AM
  5. Replies: 1
    Last Post: Jul 10, 2012, 11:16 AM

Posting Permissions