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 [2009/11/28 08:07] 127.0.0.1 external edit |
wiki:custom_formatter [2011/09/17 13:50] 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> | ||
Line 59: | Line 61: | ||
... | ... | ||
}); | }); | ||
- | function myunformatfunc ( cellvalue, options, cellobject) | + | |
- | { | + | |
- | // do something here | + | jQuery("#grid_id").jqGrid({ |
- | return unformated_value; | + | ... |
- | } | + | colModel: [ |
+ | ... | ||
+ | {name:'price', index:'price', width:60, align:"center", editable: true, formatter:imageFormat, unformat:imageUnFormat}, | ||
+ | ... | ||
+ | ] | ||
+ | ... | ||
+ | }); | ||
+ | |||
+ | function imageFormat( cellvalue, options, rowObject ){ | ||
+ | return '<img src="'+cellvalue+'" />'; | ||
+ | } | ||
+ | function imageUnFormat( cellvalue, options, cell){ | ||
+ | return $('img', cell).attr('src'); | ||
+ | } | ||
</script> | </script> | ||
</code> | </code> | ||
Line 134: | Line 149: | ||
colModel: [ | colModel: [ | ||
... | ... | ||
- | {name:'price', index:'price', width:60, align:"center", editable: true, formatter:currencyFmatter}, | + | {name:'price', index:'price', width:60, align:"center", editable: true, formatter:'currencyFmatter'}, |
... | ... | ||
] | ] | ||
Line 140: | Line 155: | ||
}); | }); | ||
</code> | </code> | ||
- | Note that in this case you will not to specify the unformat function. | + | Note that in this case you will not need to specify the unformat function. |