MCPcopy Index your code
hub / github.com/Lobos/react-ui / renderBody

Method renderBody

src/Table.js:158–201  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

156 }
157
158 renderBody (data) {
159 const { selectAble, headers } = this.props;
160
161 if (!Array.isArray(data)) {
162 return <tbody><tr><td colSpan={headers.length}>{data}</td></tr></tbody>;
163 }
164
165 const headerKeys = headers.map((h) => {
166 return h.name || hashcode(h);
167 });
168
169 let trs = data.map((d, i) => {
170 let tds = [];
171 if (selectAble) {
172 tds.push(
173 <td className="td-checkbox" key="checkbox">
174 <input checked={d.$checked} onChange={this.onSelect.bind(this, i)} type="checkbox" />
175 </td>
176 );
177 }
178 let rowKey = d.id ? d.id : hashcode(d);
179 headers.map((h, j) => {
180 if (h.hidden) {
181 return;
182 }
183 let content = h.content,
184 tdStyle = {};
185 if (typeof content === 'string') {
186 content = substitute(content, d);
187 } else if (typeof content === 'function') {
188 content = content(d);
189 } else {
190 content = d[h.name];
191 }
192 if (h.width) {
193 tdStyle.width = h.width;
194 }
195 tds.push(<td style={tdStyle} key={headerKeys[j]}>{content}</td>);
196 });
197 return <tr key={rowKey}>{tds}</tr>;
198 });
199
200 return <tbody>{trs}</tbody>;
201 }
202
203 renderHeader () {
204 let headers = [];

Callers 1

Table.jsFile · 0.80

Calls 2

hashcodeFunction · 0.90
substituteFunction · 0.90

Tested by

no test coverage detected