Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
wiki:custom_formatter [2010/06/03 14:17] manu |
wiki:custom_formatter [2011/09/17 13:51] artemeey |
||
---|---|---|---|
Line 47: | Line 47: | ||
The answer is: You can use your own custom unformatter function to do that. This function can be used in colModel | The answer is: You can use your own custom unformatter function to do that. This function can be used in colModel | ||
+ | |||
+ | Show image and edit image's path: | ||
<code javascript> | <code javascript> | ||
<script> | <script> | ||
+ | |||
+ | |||
jQuery("#grid_id").jqGrid({ | jQuery("#grid_id").jqGrid({ | ||
... | ... | ||
colModel: [ | colModel: [ | ||
... | ... | ||
- | {name:'price', index:'price', width:60, align:"center", editable: true, unformat:myunformatfunc}, | + | {name:'price', index:'price', width:60, align:"center", editable: true, formatter:imageFormat, unformat:imageUnFormat}, |
... | ... | ||
] | ] | ||
... | ... | ||
}); | }); | ||
- | function myunformatfunc ( cellvalue, options, cellobject) | + | |
- | { | + | function imageFormat( cellvalue, options, rowObject ){ |
- | // do something here | + | return '<img src="'+cellvalue+'" />'; |
- | return unformated_value; | + | } |
- | } | + | function imageUnFormat( cellvalue, options, cell){ |
+ | return $('img', cell).attr('src'); | ||
+ | } | ||
</script> | </script> | ||
</code> | </code> |