In List view, change whole row color like as odd and even.
@mohsininspire I donât think that you can change the row color unless you create a plugin that extend the ListView js file. But instead you can change the indicator color and you can count for odd and even rows.
var _count = 1;
function _isOdd(n) { return n > 0 && (n % 2) == 1; }
frappe.listview_settings['Doctype Name'] = {
get_indicator(doc) {
// customize indicator color
if (_isOdd(_count++)) {
return [__("Odd"), "red", "odd,=,Yes"];
} else {
return [__("Even"), "green", "odd,=,No"];
}
},
};
2 Likes
please guide me more
any luck??
Just include a small CSS snippet⌠Can be done through a custom app or a Client Script.
can you guide me more about custom app
See these docs about how to inject CSS via custom app:
https://frappeframework.com/docs/user/en/python-api/hooks#javascript-css-assets
Hello @ibashirbwn ,Try this
frappe.listview_settings[âDoctype_Nameâ] = {
refresh: function (listview) {
$(â.list-row-containerâ).each(function(i,onj){
if (i%2===0){
$(this).css(âbackground-colorâ, âcyanâ);
}
})
- Create New Client Script
- Select the Doctype e.g Delivery Note
- Change the field value âApply Toâ from default Form to List
Script code:
frappe.listview_settings['Delivery Note'] = {
refresh: function (listview) {
$(".list-row-container .list-row").each(function (i, obj) {
if (i % 2 === 0) {
$(this).css('background-color', '#e0e0e0');
} else {
$(this).css('background-color', '#f9f9f9');
}
});
}
};
3 Likes