-1

// (eg:if cell content are "YES" or "NO"...then if its "YES" then its color must be blue)I have given a link to "YES" where new page opens ....I tried it but text color changes to blue after I click on the link for "YES".

<style>
.clickData{
    text-align: center;
    text-decoration: underline;
    -moz-text-decoration-color: red; 
    text-decoration-color: red;
    font: bold;
    cursor: pointer;
    color:blue;
    weightfont:bold;
}
</style>




onCellSelect: function(rowid, icol, cellcontent, e) {
if (icol === 10 && cellcontent !== "N/A") {
var ro_code = $('#rep').jqGrid('getCell', rowid, 'RO_CODE');
var insp_no = $('#rep').jqGrid('getCell', rowid, 'Inspection No');
var insp_date = $('#rep').jqGrid('getCell', rowid, 'Inspection Date');
InspComplete(ro_code, insp_no, insp_date);
tr = $("#rep")[0].rows.namedItem(rowid), 
td = tr.cells[icol];
 $(td).addClass("clickData").css("color", "blue");
} else {
tr = $("#rep")[0].rows.namedItem(rowid), 
td = tr.cells[icol];
$(td).removeClass("clickData");
}


<script>
function InspComplete(ro_code, insp_no, insp_date) {
var popupWindow = null;
popupWindow = window.open('./Inspection/Summary/completeInsp.jsp?prepage=true&rep_type=VIEW&ro_code=' + ro_code + '&insp_no=' + insp_no + '&insp_date=' + insp_date, '_blank', 'scrollbars=1,width=1300,height=600');
popupWindow.focus();
}
</script>
Hiren
  • 1
  • 1
  • @Vikrant Damn Victor, what does that mean! – Mathemats Mar 27 '15 at 06:24
  • dude, don't take it wrong way, i meant Code to be mentioned in question! that is it! – Vikrant Mar 27 '15 at 06:25
  • i mentioned the code below – Hiren Mar 27 '15 at 06:51
  • You use `icol === 10` in `onCellSelect`. Which column is it? How the column and the columns `'RO_CODE'`, `'Inspection No'` and `'Inspection Date'` are defined? Do you really use `name: 'Inspection Date'`??? You should don't use spaces in `name` of `colModel` because it will be used to construct `id` attributes. Spaces are not allowed in `id` in HTML5. – Oleg Mar 27 '15 at 09:45
  • icol===10 is the column where link is given (for "YES") and there is no popup (for "N/A"(i.e. "NO"))...rocode,inspection no and date i have fetched to pass to other page to generate report – Hiren Mar 27 '15 at 10:12

1 Answers1

0

I'm not sure that I understand your requirements corectly, but I suppose that you need use cellattr callback in colModel. See the answer, the answer and this one

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • I want the cell content to be in blue color if its "YES".I have provided a pop up window if the cellcontent is "YES"...so by default i want it in blue color but the color changes after i click on the link – Hiren Mar 27 '15 at 07:07
  • look at the code...there is no formatter used....function is called on the column no – Hiren Mar 27 '15 at 09:29
  • @Hiren: The **formatter** need be used to format the results like convert `true` to cheched box and `false` to unckecked box or to display `2015-03-27` as `3/27/2015` and so on. In other words the formatter need be to generate **the content** of the cell. On the other side `cellattr` can be used to set class, style, tooltip and other **attributes** of the cell (color, background color and so on). You can still use *any* formatter and combine it with `cellattr`. – Oleg Mar 27 '15 at 09:41
  • :Can u give any example? – Hiren Mar 27 '15 at 10:05
  • I posted you already some referenced like [the demo](http://www.ok-soft-gmbh.com/jqGrid/SimpleLocalGridWithAddClass.htm) from [the answer](http://stackoverflow.com/a/6048865/315935). The code of `cellattr` can depend on `datatype` which you use and from the format of input data. You don't posted the information. – Oleg Mar 27 '15 at 10:09
  • yes..sorry.datatype is json and the data is from oracle database – Hiren Mar 27 '15 at 10:34
  • @Hiren: Sorry, but I'm a little tired to ask one thing after another one. The format of the third parameter of `cellattr` depend on the format of input data which you use for jqGrid. If you use `datatype: "json"`, than the usage of `loadonce: true` can be important and the **format of items in the server response**. For example if you use `{"RO_CODE": "code1", ...}` then you can use `rowdata.RO_CODE` in the `cellattr`. If you use `{id:"td1", cell: ["code1", ...]}` then `rowdata` will be array too and you should use something like `rowdata[0]` *at the first load* of the grid. – Oleg Mar 27 '15 at 10:54