javascript - Dojo Toolkit - How to change the color of a table column with a button? -


i complete beginner dojo , have been following tutorials on website. trying dynamically change background color of table when pressing button. here html code:

<!doctype html> <html>     <head>         <meta charset="utf-8">          <link rel="stylesheet" href="dijit/themes/claro/claro.css">         <!-- load dojo -->         <script>dojoconfig = {parseonload: true}</script>         <script src="dojo/dojo.js" data-dojo-config="async: true"></script>         <script> require(['mymodule.js']); </script>          <title>table</title>      </head>      <body class="claro">         <h1 id="greeting">test table</h1>      <table data-dojo-type="dojox.grid.datagrid" id="tablecontainer">         <thead>             <tr>                 <th field="col1">company</th>                 <th field="col2">contact</th>                 <th field="col3">country</th>             </tr>             <tr>                 <td>alfreds futterkiste</td>                 <td>maria anders</td>                 <td>germany</td>             </tr>         </thead>     </table>      <button id="progbuttonnode" type="button"></button>     <div id="result1"></div>     </body> </html> 

this mymodule.js file. when click button function not seem work. when use commented out code works fine

require(["dijit/form/button", "dojo/dom", "dojo", "dojo/domready!"], function(button, dom){     // create button programmatically:     var mybutton = new button({         label: "click me!",         onclick: function(dojo){             //dom.byid("result1").innerhtml += "thank you! ";             dojo.style("tablecontainer", "background-color", "red");         }     }, "progbuttonnode").startup(); }); 

you need apply style on node so

dojo.style(dom.byid("tablecontainer"), "background-color", "red"); 

should work you. other way change css class. let's have css class want , want apply onclick of button. can like

dijit.byid('yourgid').set('class','yourcssclass'); 

you can use onstylerow event ro style rows


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -