Posted on April 20, 2015 at 04:31 AM
Sometimes you need to strike off a row in ExtJS grids, this can be easily done by CSS code.
The CSS code will look like this,
.strike-through-row {
text-decoration: none;
background-image: -webkit-linear-gradient(transparent 7px,#6F6B6B 7px,#6F6B6B 9px,transparent 9px);
background-image: -moz-linear-gradient(transparent 7px,#6F6B6B 7px,#6F6B6B 9px,transparent 9px);
background-image: -ms-linear-gradient(transparent 7px,#6F6B6B 7px,#6F6B6B 9px,transparent 9px);
background-image: -o-linear-gradient(transparent 7px,#6F6B6B 7px,#6F6B6B 9px,transparent 9px);
background-image: linear-gradient(transparent 7px,#6F6B6B 7px,#6F6B6B 9px,transparent 9px);
}
In ExtJS columns declaration we have a function named renderer.
“A renderer is an ‘interceptor’ method which can be used to transform data (value, appearance, etc.) before it is rendered.” (From ExtJS docs).
This function can define CSS classes the cell can have. So in this function we write the following code,
renderer : function (value, meta, record) {
meta.tdCls = 'strike-through-row';
return value;
}
and the current cell will be marked as strike off. We can check for any condition and then apply the class for some specific cells as per our requirements.
The result will look something like this,
In this example I am striking off the row only when the age is less than 18 if it is greater than 18 then we don’t strike off the row.
renderer : function (value, meta) {
// Renderer function of age column
if(value < 18) {
meta.tdCls = 'strike-through-row';
}
return value;
}
You can check also for some other column’s data of the row in renderer function by using the third parameter of the function record.
So if you want to strike off name also depending on age in the above example you can check that in name column’s renderer function as :
renderer : function (value, meta, record) {
// Renderer function of name column
var data = record.data;
var age = data['age'];
if(age < 18) {
meta.tdCls = 'strike-through-row';
}
return value;
}
Happy Coding. 🙂
Queues and task scheduler in laravel works like a charm. But it can fail in a certain case. In this post, I am going to explain the case where it c...
Some services run on different ports and to access them in the browser we have to mention the port number also. For ex : SonarQube : 9000 [http://1...
Sometimes you need to strike off a row in ExtJS grids, this can be easily done by CSS code. The CSS code will look like this, .strike-through-row {...
When you are working on a laravel project there is some basic setup that needs to be done for each install of the project. Like Permissions for ...
In this blog, we are going to take a look into Laravel Queues. Queues allow you to defer the processing of a time-consuming task, such as sending a...
PARTIALS Let’s say we have a structure like the following : data = { students : [{ name : ‘ABC’, roll : 1 }, { name : ‘DEF&...
PHP 8 has been officially released in November 2020! This new major update brings many optimizations and powerful features to the language. This...
ProxySQL is a high-performance SQL proxy. ProxySQL runs as a daemon watched by a monitoring process. The process monitors the daemon and restarts i...
Time is important. We should not waste it doing trivial things. Automate things wherever possible.