के साथ गतिशील राशि वाली तालिका के साथ एक तालिका बना रहा है, मैं एक printlet मानचित्र बनाने के साथ एक प्रतिक्रिया.जेएस तालिका बनाने की कोशिश कर रहा हूँ। मेरे पास यह डेटा है और मैं डेटा को सही तरीके से प्राप्त करने में सक्षम हूं, लेकिन मैं तालिका को सही तरीके से नहीं बना सकता। मैं हेडर देखने में सक्षम हूं क्योंकि वे हार्डकोड हैं, लेकिन मैं पंक्तियों को देखने में सक्षम नहीं हूं। मेरे पास कोड में console.log() बिंदुओं पर डेटा को समझाने के लिए एक तस्वीर भी है।React.js एक संपादन योग्य कॉलम
/* Table React Component */
var TABLE_CONFIG = {
sort: { column: "Zone", order: "desc" },
columns: {
col1: { name: "Zone", filterText: "", defaultSortOrder: "desc" },
col2: { name: "Population", filterText: "", defaultSortOrder: "desc" }
}
};
var Table = React.createClass({
getInitialState: function() {
var tabledata = [];
var length = _.size(testJSON.zones);
for(i = 0; i < length; i++) {
var name = _.keys(testJSON.zones)[i];
var population = testJSON.zones[name].population.value;
if(name == "default") {
population = testJSON.zones[name].population.default.value;
}
tabledata[i] = {name, population};
}
console.log(tabledata);
return {zones: tabledata};
},
render: function() {
var rows = [];
this.state.zones.forEach(function(zone) {
rows.push(<tr Population={zone.population} Zone={zone.name} />);
}.bind(this));
console.log(rows);
return (
<table>
<thead>
<tr>
<th>Zone</th>
<th>Population</th>
</tr>
</thead>
<tbody>{rows}</tbody>
</table>
);
}
});
यहाँ आप पूर्ण में console.log(tabledata)
लाइन के साथ ही पहली वस्तु देख सकते हैं console.log(rows)
में
मैं नीचे चित्र की तरह कुछ देखना चाहेंगे: यहाँ कोड है। कृपया ध्यान दें मैं जोन स्तंभ करना चाहते संपादन योग्य इनपुट नहीं होने के लिए है, लेकिन जनसंख्या संपादित किए जा रहे हैं:
यहाँ एक सरल तालिका घटक बनाने प्रतिक्रिया में की एक काफी संक्षिप्त उदाहरण है। यह मेरी मदद की। https://gist.github.com/ChaseWest/1935d08b156ae04b85d2 – devdanke