0

Here is my colModel:

[{ name: 'Status', index: 'Status', width: 150, align: 'left', resizable: false },
{name:'Blocked',index:'Blocked',width:50,align:'left',resizeable:false}]

i want that on Blocked Status in Status column,my Blocked column will show an image.How can i do that?

Muhammad Ali
  • 853
  • 1
  • 10
  • 18
  • Do you tried to use ]custom formatter](http://www.trirand.com/jqgridwiki/doku.php?id=wiki:custom_formatter)? In [the answer](http://stackoverflow.com/a/13765086/315935) for example you can find [the demo](http://www.ok-soft-gmbh.com/jqGrid/AbhishekSimon13.htm) which creates icons, links and allows to execute some Javascript code if the user click on the link. – Oleg Jul 25 '14 at 10:22
  • Oleg what to code in that formatter.Can you give me piece of code?? – Muhammad Ali Jul 25 '14 at 11:37
  • The code of `formatter` function is already posted in [the answer](http://stackoverflow.com/a/13765086/315935) which I referenced before. Moreover you can see full source code of [the demo](http://www.ok-soft-gmbh.com/jqGrid/AbhishekSimon13.htm) if you open context menu by click on the right mouse button and choose "View page source" or "View source" depend on the web browser which you use. – Oleg Jul 25 '14 at 11:58
  • I do this using rowObject which is array of current row data.I am then hardcode like this.`if(rowObject[1]=="Blocked") return 'image address'`.Is it true way?? – Muhammad Ali Jul 25 '14 at 12:07
  • You should append the text of your question with more detailes (JavaScript code and the test data which shows **the format** of `rowObject`). Moreover it's important which `datatype` you use and whether you use `loadonce: true` or not. – Oleg Jul 25 '14 at 12:10
  • `function checkStatusFlag(cellvalue, options, rowObject) { if (rowObject[1] == "Pending") { return "
    " } else { return ""; } } ` This is my formatter which in put in Blocked collumn
    – Muhammad Ali Jul 25 '14 at 12:25
  • Please **don't post long code in the comments**. Instead of that you should click "edit" link under your question and modify the text of the question. It simplify reading of your question (for other people too). I asked you to post **test data** together with the code. I wrote also: **it's important which datatype you use and whether you use `loadonce: true` or not**. Only after having the information it will be clear whether `rowObject[1]` is correct way to access the data which you need. In some cases `rowObject.Status` will be correct. In other one have to test `$.isArray(rowObject)` before – Oleg Jul 25 '14 at 12:50
  • rowObject.Status is undefined in my case .I don't use loadonce – Muhammad Ali Jul 25 '14 at 13:02
  • In the case I don't understand your current problem. Get `rowObject[1]` or `rowObject[0]` you the required data? What problem you have with `checkStatusFlag` as formatter? – Oleg Jul 25 '14 at 13:22

0 Answers0