Note that there are some explanatory texts on larger screens.

plurals
  1. POdisable/enable dropdown list options based on filtered D3.js data
    primarykey
    data
    text
    <p>I have two dropdown lists that are dynamically populated from a database using PHP. They contain all values for a specified column e.g one contains all values for parameterType and the other all values for dateTimeTaken. </p> <p>Is there any way to disable any of these options when the data is filtered and some of these options may no longer be applicable - basically I'm asking if dynamically populated dropdown lists can be updated when the data is, if so, how this can be accomplished?</p> <p><strong>UPDATE:</strong></p> <p>My data is in following format:</p> <pre><code> [{"dateTimeTaken":"2013-01-01 14:05:14", "reading":"0.90000", "parameterType":"Flouride", "inspectionPoint_id":"2"}.... </code></pre> <p>and I've attempted to do this using following code - but not doing anything??</p> <pre><code> d3.json("HistoricData.php", function(error,data) { var filtered_data = data.filter(function(d) { return d.inspectionPoint_id == i;}) filtered_data.forEach(function(d) { d.dateTimeTaken = parseDate(d.dateTimeTaken); d.reading = +d.reading; d.parameterType = d.parameterType; d.inspectionPoint_id = +d.inspectionPoint_id; }); var check = d3.select("selectparameter")//select dropdown list check.selectAll("option").each(checkOption);//select all options //for any of the options that don't match the parameterType's //from the filtered dataset set display to none var checkOption = function (d, e) { if(e !== d.values(d.parameterType)){ return d3.select(this).attr("display", "none"); } }; </code></pre> <p><strong>UPDATE 2</strong></p> <pre><code> d3.select("#selectparameter") .append("select") .selectAll("option") .data(filtered_data) .enter().append("option") .text(function(d) { return d.parameterType; }) </code></pre> <p><img src="https://i.stack.imgur.com/c0L79.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload