get text from jqgrid cell value

codingBliss

I have inserted an image and text in jqgrid cells using a formatter as follows:

function myFormatter (cellvalue, options, rowObject)
{  
      switch(cellvalue){
        case 'Unknown':         newCell="<img src='../../Content/images/ui-flag_green.png' />"+cellvalue;break;//unknown
        case 'Informational' :  newCell="<img src='../../Content/images/ui-flag_green.png' />"+cellvalue;break; //informational
        case 'Warning' :        newCell="<img src='../../Content/images/ui-flag_green.png' />"+cellvalue;break; //warning       
        }                 
    return newCell;
}

I need to check each value of my cell for another operation.So I need to get only the text part of the cell value.

Something like this:

var rows =myGrid.getRowData();
//for(var i=1;i<=rows;i++)
for(var i=1;i<=rows.length;i++)
{
        var rowdata =myGrid.getRowData(i);
        var Val = rowdata.myColumn;    

        switch(Val){
        case 'Unknown':         do this 1;break;//unknown
        case 'Informational' :  do THIS 2;break; //informational
        case 'Warning' :        do this 3;break; //warning    
}

The Val obtained is the image but my requirement is the text .

Aneesh Vijendran

Why don't you add a title and id to the image in the formatter like below:

something like this :

<img id='cusmFrmt_"+rowObject.id+"' title='"+cellvalue+"'
src='../../Content/images/ui-flag_green.png' />"+cellvalue;

So formatter would be:

function myFormatter (cellvalue, options, rowObject)
{  
          switch(cellvalue){
            case 'Unknown':         newCell="<img id='cusmFrmt_"+rowObject.id+"' title='"+cellvalue+"' src='../../Content/images/ui-flag_green.png' />"+cellvalue;break;//unknown
            case 'Informational' :  newCell="<img id='cusmFrmt_"+rowObject.id+"' title='"+cellvalue+"' src='../../Content/images/ui-flag_green.png' />"+cellvalue;break; //informational
            case 'Warning' :        newCell="<img id='cusmFrmt_"+rowObject.id+"' title='"+cellvalue+"' src='../../Content/images/ui-flag_green.png' />"+cellvalue;break; //warning       
            }                 
        return newCell;
}

After that in your getRow stuff:

var imgObject = $('#cusmFrmt_'+rowdata.id);
// get cell value
var cellValueTxt = imgObject.attr('title');

So actually it will look like this:

var rows =myGrid.getRowData();
//for(var i=1;i<=rows;i++)
for(var i=1;i<=rows.length;i++)
{
        var rowdata =myGrid.getRowData(i);
        var Val = rowdata.myColumn;  
        // get image object     
        var imgObject = $('#cusmFrmt_'+rowdata.id);
        // get cell value
        var cellValueTxt = imgObject.attr('title');

        switch(cellValueTxt){
        case 'Unknown':         do this 1;break;//unknown
        case 'Informational' :  do THIS 2;break; //informational
        case 'Warning' :        do this 3;break; //warning    
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to get the particular cell value in JQgrid

From Dev

jqGrid 4.8.0 - How to get cell type or cell value using jsonmap

From Dev

How to get the value of formatted cell value of a row in jqgrid

From Dev

free-jqGrid - The numeric value is displayed instead of the text for select cell

From Dev

Cannot get a text value from a numeric cell “Poi”

From Dev

How can get text box value from into the table cell?

From Dev

JQGrid remove cell value from custom error message in inline editing

From Dev

jqGrid select text in active cell

From Dev

Get selected cell value from DataGrid Cell

From Java

Get value from the cell above

From Dev

Get value from a cell in JTable

From Dev

Get cell value from Dataset

From Dev

c# OleDbDataReader get cell value not text

From Dev

How to get value of text box embeded in cell

From Dev

How to get Select's text from jqGrid column with inline editing

From Dev

Get a cell value from a row based on another cell value

From Dev

How to get text from table cell

From Dev

Get text from current editing cell in a Datagrid

From Dev

How to get text from cell to another in Excel

From Dev

How to Get text from table cell

From Dev

Get Text from Datagrid cell or Row

From Dev

jqGrid Editing – override logic to define cell value

From Dev

Change JQGrid Cell value on Button Click

From Dev

JqGrid getRowdata gives cell value on a row as string

From Java

How to get a value from a cell of a dataframe?

From Dev

Get textbox value from Excel cell

From Dev

SpreadsheetLight get numeric value from cell formula

From Dev

JQuery get cell value from row object

From Dev

Get a value from the sheet name and cell address

Related Related

HotTag

Archive