Conditional styling a row, based on column valueChanging background cell of table depending on valueWhat is the difference between old style and new style classes in Python?Styling multi-line conditions in 'if' statements?Does Python have a ternary conditional operator?How do I sort a dictionary by value?How to access environment variable values?Renaming columns in pandasDelete column from pandas DataFrameHow to iterate over rows in a DataFrame in Pandas?Select rows from a DataFrame based on values in a column in pandasDeleting DataFrame row in Pandas based on column value

Are there any cons in using rounded corners for bar graphs?

What was the intention with the Commodore 128?

Attacking the Hydra

Scam? Phone call from "Department of Social Security" asking me to call back

Weird resistor with dots around it on the schematic

What is the spellcasting ability of a Barbarian Totem Warrior?

What should we do with manuals from the 80s?

What is the purpose/function of this power inductor in parallel?

When was "Fredo" an insult to Italian-Americans?

Do I need to start off my book by describing the character's "normal world"?

Understanding a part of the proof that sequence that converges to square root of two is decreasing.

Build a mob of suspiciously happy lenny faces ( ͡° ͜ʖ ͡°)

What modifiers are added to the attack and damage rolls of this unique longbow from Waterdeep: Dragon Heist?

Ghost house where the house only appeared once a year for it was the ghost

What is the opposite of "hunger level"?

What if a restaurant suddenly cannot accept credit cards, and the customer has no cash?

What are some tips and tricks for finding the cheapest flight when luggage and other fees are not revealed until far into the booking process?

QgsGeometry.length() giving wrong result?

Doesn't the speed of light limit imply the same electron can be annihilated twice?

Did Michelle Obama have a staff of 23; and Melania have a staff of 4?

Minimum population for language survival

Typesetting "hollow slash"

Why does Japan use the same type of AC power outlet as the US?

How do I ask for 2-3 days per week remote work in a job interview?



Conditional styling a row, based on column value


Changing background cell of table depending on valueWhat is the difference between old style and new style classes in Python?Styling multi-line conditions in 'if' statements?Does Python have a ternary conditional operator?How do I sort a dictionary by value?How to access environment variable values?Renaming columns in pandasDelete column from pandas DataFrameHow to iterate over rows in a DataFrame in Pandas?Select rows from a DataFrame based on values in a column in pandasDeleting DataFrame row in Pandas based on column value






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I would like to style row based on a value of a column, I currently have this code:



import dash
import dash_table
import pandas as pd

df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/solar.csv')

app = dash.Dash(__name__)
print(["name": i, "id": i for i in df.columns])
app.layout = dash_table.DataTable(
id='table',
columns=["name": i, "id": i for i in df.columns],
data=df.to_dict("rows"),
style_data_conditional=[

'if':
'column_id': 'Number of Solar Plants',
'filter': '"Number of Solar Plants" > num(100)'
,
'backgroundColor': '#3D9970',
'color': 'white',

],
)

if __name__ == '__main__':
app.run_server(debug=True)


Which produces the following result:



enter image description here



But what I really want is for the rows (tr 1 and 8 in this case) to be styled with a green background, not just the cells.



What can I do to achieve this?










share|improve this question


























  • If you don't mind putting in a bit of normal javascript, you can probably use a solution similar to what's given in this related question.

    – 0 0
    Mar 27 at 12:40

















0















I would like to style row based on a value of a column, I currently have this code:



import dash
import dash_table
import pandas as pd

df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/solar.csv')

app = dash.Dash(__name__)
print(["name": i, "id": i for i in df.columns])
app.layout = dash_table.DataTable(
id='table',
columns=["name": i, "id": i for i in df.columns],
data=df.to_dict("rows"),
style_data_conditional=[

'if':
'column_id': 'Number of Solar Plants',
'filter': '"Number of Solar Plants" > num(100)'
,
'backgroundColor': '#3D9970',
'color': 'white',

],
)

if __name__ == '__main__':
app.run_server(debug=True)


Which produces the following result:



enter image description here



But what I really want is for the rows (tr 1 and 8 in this case) to be styled with a green background, not just the cells.



What can I do to achieve this?










share|improve this question


























  • If you don't mind putting in a bit of normal javascript, you can probably use a solution similar to what's given in this related question.

    – 0 0
    Mar 27 at 12:40













0












0








0








I would like to style row based on a value of a column, I currently have this code:



import dash
import dash_table
import pandas as pd

df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/solar.csv')

app = dash.Dash(__name__)
print(["name": i, "id": i for i in df.columns])
app.layout = dash_table.DataTable(
id='table',
columns=["name": i, "id": i for i in df.columns],
data=df.to_dict("rows"),
style_data_conditional=[

'if':
'column_id': 'Number of Solar Plants',
'filter': '"Number of Solar Plants" > num(100)'
,
'backgroundColor': '#3D9970',
'color': 'white',

],
)

if __name__ == '__main__':
app.run_server(debug=True)


Which produces the following result:



enter image description here



But what I really want is for the rows (tr 1 and 8 in this case) to be styled with a green background, not just the cells.



What can I do to achieve this?










share|improve this question
















I would like to style row based on a value of a column, I currently have this code:



import dash
import dash_table
import pandas as pd

df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/solar.csv')

app = dash.Dash(__name__)
print(["name": i, "id": i for i in df.columns])
app.layout = dash_table.DataTable(
id='table',
columns=["name": i, "id": i for i in df.columns],
data=df.to_dict("rows"),
style_data_conditional=[

'if':
'column_id': 'Number of Solar Plants',
'filter': '"Number of Solar Plants" > num(100)'
,
'backgroundColor': '#3D9970',
'color': 'white',

],
)

if __name__ == '__main__':
app.run_server(debug=True)


Which produces the following result:



enter image description here



But what I really want is for the rows (tr 1 and 8 in this case) to be styled with a green background, not just the cells.



What can I do to achieve this?







python python-3.x datatables styling plotly-dash






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 27 at 13:06







Hula Hula

















asked Mar 27 at 12:34









Hula HulaHula Hula

2962 silver badges12 bronze badges




2962 silver badges12 bronze badges















  • If you don't mind putting in a bit of normal javascript, you can probably use a solution similar to what's given in this related question.

    – 0 0
    Mar 27 at 12:40

















  • If you don't mind putting in a bit of normal javascript, you can probably use a solution similar to what's given in this related question.

    – 0 0
    Mar 27 at 12:40
















If you don't mind putting in a bit of normal javascript, you can probably use a solution similar to what's given in this related question.

– 0 0
Mar 27 at 12:40





If you don't mind putting in a bit of normal javascript, you can probably use a solution similar to what's given in this related question.

– 0 0
Mar 27 at 12:40












1 Answer
1






active

oldest

votes


















1














to fix your issue you just have to remove the column_id parameter in your style_data_conditional. So all the row will be colored in green.



You should do this:



style_data_conditional=[

'if':
'filter': '"Number of Solar Plants" > num(100)'
,
'backgroundColor': '#3D9970',
'color': 'white',

]





share|improve this answer

























  • Wow that was easy... Thanks

    – Hula Hula
    Mar 27 at 13:35











  • you are welcome :-)

    – Maaz
    Mar 27 at 13:37










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55377338%2fconditional-styling-a-row-based-on-column-value%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














to fix your issue you just have to remove the column_id parameter in your style_data_conditional. So all the row will be colored in green.



You should do this:



style_data_conditional=[

'if':
'filter': '"Number of Solar Plants" > num(100)'
,
'backgroundColor': '#3D9970',
'color': 'white',

]





share|improve this answer

























  • Wow that was easy... Thanks

    – Hula Hula
    Mar 27 at 13:35











  • you are welcome :-)

    – Maaz
    Mar 27 at 13:37















1














to fix your issue you just have to remove the column_id parameter in your style_data_conditional. So all the row will be colored in green.



You should do this:



style_data_conditional=[

'if':
'filter': '"Number of Solar Plants" > num(100)'
,
'backgroundColor': '#3D9970',
'color': 'white',

]





share|improve this answer

























  • Wow that was easy... Thanks

    – Hula Hula
    Mar 27 at 13:35











  • you are welcome :-)

    – Maaz
    Mar 27 at 13:37













1












1








1







to fix your issue you just have to remove the column_id parameter in your style_data_conditional. So all the row will be colored in green.



You should do this:



style_data_conditional=[

'if':
'filter': '"Number of Solar Plants" > num(100)'
,
'backgroundColor': '#3D9970',
'color': 'white',

]





share|improve this answer













to fix your issue you just have to remove the column_id parameter in your style_data_conditional. So all the row will be colored in green.



You should do this:



style_data_conditional=[

'if':
'filter': '"Number of Solar Plants" > num(100)'
,
'backgroundColor': '#3D9970',
'color': 'white',

]






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 27 at 13:13









MaazMaaz

1,3241 gold badge8 silver badges14 bronze badges




1,3241 gold badge8 silver badges14 bronze badges















  • Wow that was easy... Thanks

    – Hula Hula
    Mar 27 at 13:35











  • you are welcome :-)

    – Maaz
    Mar 27 at 13:37

















  • Wow that was easy... Thanks

    – Hula Hula
    Mar 27 at 13:35











  • you are welcome :-)

    – Maaz
    Mar 27 at 13:37
















Wow that was easy... Thanks

– Hula Hula
Mar 27 at 13:35





Wow that was easy... Thanks

– Hula Hula
Mar 27 at 13:35













you are welcome :-)

– Maaz
Mar 27 at 13:37





you are welcome :-)

– Maaz
Mar 27 at 13:37








Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55377338%2fconditional-styling-a-row-based-on-column-value%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript