我有一个类似的功能,我想将单元格放在网格列的左侧和右侧,现在它只是一个一个地放置,对于左侧网格列,它应该是function PortIPAddress(Port: string): string;
var
buf: PWideChar;
pd: PRINTER_DEFAULTS;
c,
d,
bs,
hXcv: cardinal;
begin
Result := 'unknown';
ZeroMemory(@pd, SizeOf(PRINTER_DEFAULTS));
pd.DesiredAccess := SERVER_ACCESS_ADMINISTER;
if OpenPrinter(PAnsiChar(Format(',XcvPort %s', [Port])), hXcv, @pd) then
begin
XcvData(hXcv, 'IPAddress', nil, 0, nil, 0, @bs, @c);
GetMem(buf, bs);
try
if XcvData(hXcv, 'IPAddress', nil, 0, buf, bs, @d, @c) then
Result := buf;
finally
FreeMem(buf, bs);
end;
end;
ClosePrinter(hXcv);
end;
,对于右边的那个可以是<GridColumn gridUnits={6}>
,是否有根据索引来区别对待的东西,如果是奇数,则属于左Grid Column,如果是偶数,则属于右Grid Column?
如何实现?
<GridColumn gridUnits={6} position='last'>
答案 0 :(得分:1)
可能可以执行以下操作:
generateEquipmentListByCell(printerCellMap, dryerCellMap) {
const equipmentKey = {...printerCellMap, ...dryerCellMap};
if (!_.isEmpty(equipmentKey)) {
return (
<div>
<GridColumn gridUnits={6}>
{
Object.keys(equipmentKey).map((key, index) => (
(index % 2) ?
<EquipmentCell printerList={printerCellMap[key]}
dryerList={dryerCellMap[key]}
index={index}/> : null
));
}
</GridColumn>
<GridColumn gridUnits={6} position="last">
{
Object.keys(equipmentKey).map((key, index) => (
(index % 2 !== 0) ?
<EquipmentCell printerList={printerCellMap[key]}
dryerList={dryerCellMap[key]}
index={index}/> : null
));
}
</GridColumn>
</div>
);
}
}
要求您执行两个循环,但它应该可以实现您的目标。如果不确定%
运算符的作用。可以找到文档here。