EasyUI Forum
May 16, 2024, 09:15:25 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Highlighter  (Read 8732 times)
deck
Newbie
*
Posts: 4


View Profile
« 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
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: November 08, 2013, 06:46:21 PM »

Please use 'formatter' function to format that column's value.
Logged
deck
Newbie
*
Posts: 4


View Profile
« Reply #2 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
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 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>
Logged
deck
Newbie
*
Posts: 4


View Profile
« Reply #4 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;
}
Logged
deck
Newbie
*
Posts: 4


View Profile
« Reply #5 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
« Last Edit: November 11, 2013, 04:29:30 AM by deck » Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!