0

I have a jqgrid which has been loaded from dwr call. It is a dynamic table. In POJO I set 3 status and generate dynamic checkbox.

This is my pojo code.

   private String cBox;

   public String cBox()
   {

    if (style() == D)
    {
        return i l create checkbox here;
    }
    else if (style() == E)
    {
        return checkbox will be created ;
    }
    else if (getStatusFlag() == F)
    {
        return checkbox will be created;
    }


    return cBox;
}

I load jqgrid like this.

colNames : ['Code no.', 'Title' ],
                colModel : [{
                    name : 'code_no',
                    index : 'code_no',
                    width : '100%',
                    sorttype : 'text',
                    align : 'left'
                },
                                    {
                    name : 'title',
                    index : 'title',
                    width : '100%',
                    sorttype : 'text',
                    align : 'left'
                }]

I want to make the entire row bold, if the style is D and I want to make the background color of the row blue when the color is E. How should I customize the jqgrid row ?

sahana
  • 601
  • 5
  • 12
  • 33

1 Answers1

3

The following function will examine each column cell value and if the TestValue is matching add the class to the row.

    rowattr: function (rd) {
           if (rd.ColumnName == TestValue) { return {"class": "RowBoldClass"}; }//if
    },

and the matching class

RowBoldClass { font-weight:bold; .....
Mark
  • 3,123
  • 4
  • 20
  • 31
  • could you please explain me the code. what is that rd inside the function. What should I give inside the test value ? – sahana Apr 17 '13 at 13:02
  • where should I give the rowattr ? I want to make the entire row bold or change background color. – sahana Apr 17 '13 at 13:03
  • The rowattr would be included as part of the setup of your jqGrid, the Class you assign is the part that takes care of the style applied to the row. – Mark Apr 17 '13 at 13:05
  • The TestValue is whatever value you are testing for to determine if you want the row to be in bold or have a different background color. – Mark Apr 17 '13 at 13:06
  • could you please show me a sample? I am really not aware about jqgrid setup. – sahana Apr 17 '13 at 13:09
  • @sahana: [The answer](http://stackoverflow.com/a/10531680/315935) provide [simple demo](http://www.ok-soft-gmbh.com/jqGrid/SimpleLocalGridChangeRowBackgroundBasedOnCheckboxes3.htm). @Mark: you should better rename `rd.Cell Value` to `rd.ColumnName` to have correct syntax. – Oleg Apr 17 '13 at 13:18
  • @Oleg I already saw that post and my query is, where to fit in inside my grid. should I give that outside colmodel or colname? If not where should I give that? – sahana Apr 17 '13 at 13:20
  • @sahana it is outside your colmodel and colname, this is a separate part of jqGrid you are setting up, not a property of the columnModel/columnName. – Mark Apr 17 '13 at 13:24
  • @Mark I will make it and let you know the results. Thanks !! – sahana Apr 17 '13 at 13:25
  • @Mark the css part can be given inside any css file that i have given in my jsp right ? – sahana Apr 17 '13 at 13:29
  • Any CSS file that your project/page can access. – Mark Apr 17 '13 at 13:37
  • 1
    @sahana: If you opens source of [my old demo](http://www.ok-soft-gmbh.com/jqGrid/SimpleLocalGridChangeRowBackgroundBasedOnCheckboxes3.htm) you will see all what you need. – Oleg Apr 17 '13 at 13:50