EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: deck on November 08, 2013, 11:36:58 AM



Title: Highlighter
Post by: deck on November 08, 2013, 11:36:58 AM
Hello,

how can I highlight part of the word in datagrid cell in just one column?

deck


Title: Re: Highlighter
Post by: stworthy on November 08, 2013, 06:46:21 PM
Please use 'formatter' function to format that column's value.


Title: Re: Highlighter
Post by: deck on November 09, 2013, 03:40:58 AM
Thanx,

could you please give me some code to span yellow background

behind the part of the word in cell

deck


Title: Re: Highlighter
Post by: stworthy on November 09, 2013, 07:27:47 AM
The code below shows how to highlight the 'attr1' column with 'ge' string set to red color.

Code:
<script>
function formatAttr(value){
var v = value.replace(/ge/g,'<span style="color:red">ge</span>');
return v;
}
</script>
<th data-options="field:'attr1',formatter:formatAttr,width:250,editor:'text'">Attribute</th>


Title: Re: Highlighter
Post by: deck on November 09, 2013, 09:01:38 PM
Thanx,

I need to place value from input box instead of 'ge' like this

Code:
function formatAttr(value){
var v = value.replace(/('#input').val()/g,'<span style="background-color: #FFFF00">('#input').val()</span>');
return v;
}


Title: Re: Highlighter
Post by: deck on November 10, 2013, 06:49:30 AM
I have just tried this last code it doesnt work with parameters like this

need help to put 'input' parameter into replace function