private void FieldsCellValueChanged(object sender, LayoutValueEventArgs e) { if (ListMode && Status == TableEditorStatus.Adding) { LayoutList flist = (LayoutList)sender; var query = DBList.View.Query; LayoutField ff = (LayoutField)e.Cell; if (e.Data != DBNull.Value) { query.BuildParam(ff.Name, e.Data, QQueryBuildParam.AutoLike | QQueryBuildParam.SplitString); } foreach (LayoutField field in flist.Fields) { object val = flist.ReadValue(field, (LayoutColumn)flist.ListInfo.Columns["Value"]); if (!field.Visible || val == null || val == DBNull.Value || GroupHelper.Level(field) != 0) { continue; } if (field == ff) { continue; } if (string.IsNullOrEmpty(val.ToString())) { continue; } query.BuildParam(field.Name, val, QQueryBuildParam.AutoLike | QQueryBuildParam.SplitString); } if (query.Parameters.Count == 0) { loader.Cancel(); } else if (!Table.IsSynchronized) { loader.LoadAsync(query); } //list.View.UpdateFilter(); } }
public void WriteMapItem(LayoutColumn map, int listIndex, object listItem, int sc, int sr, ref int mr, StringKeyList stringTable, List <Row> prows = null) { int tws = map.GetWithdSpan(); Row row = null; var rows = prows; if (prows == null) { rows = new List <Row>(); mr++; row = GenerateRow(mr, mc, listItem == null, stringTable); WriteCell(row.GetFirstChild <Cell>(), listItem == null ? (object)"#" : (object)(listIndex + 1), stringTable); rows.Add(row); sc = 1; } var nr = mr; foreach (var item in map) { if (item.Visible) { map.GetVisibleIndex(item, out int c, out int r); c += sc; r += sr; if (item.Count > 0) { WriteMapItem(item, listIndex, listItem, c, r, ref mr, stringTable, rows); } else { int rr = nr + r; if (rows.Count <= r) { mr++; row = GenerateRow(rr, mc, listItem == null, stringTable); rows.Add(row); } else { row = rows[r]; } object celldata = ((LayoutColumn)item).Text; if (listIndex == -2) { celldata = list.GetCollectedValue((LayoutColumn)item, group); } if (listItem != null) { object val = list.ReadValue(listItem, (ILayoutCell)item); celldata = list.FormatValue(listItem, val, (ILayoutCell)item); if (val is decimal && ((ILayoutCell)item).Format != "p") { celldata = val; } if (prows == null && c == 1 && listItem is Node) { var s = GroupHelper.Level((Node)listItem) * 4; celldata = celldata.ToString().PadLeft(celldata.ToString().Length + s, '-'); } } var cellc = (Cell)row.ChildElements.GetItem(c); WriteCell(cellc, celldata, stringTable); if (celldata is decimal) { cellc.StyleIndex = 3; } int ws = map.GetRowWidthSpan(item.Row); int hs = map.GetRowHeightSpan(item.Row, true); if (tws > ws && hs > 1) { mcells.Add(new MergeCell() { Reference = new CellRange(c, rr, c + tws - ws, rr + hs - 1).ToString() }); } else if (tws > ws) { mcells.Add(new MergeCell() { Reference = new CellRange(c, rr, c + tws - ws, rr).ToString() }); } else if (hs > 1) { mcells.Add(new MergeCell() { Reference = new CellRange(c, rr, c, rr + hs - 1).ToString() }); } } } } if (prows == null) { if (rows.Count > 1) { mcells.Add(new MergeCell() { Reference = new CellRange(0, nr, 0, nr + rows.Count - 1).ToString() }); } if (listItem is Node) { foreach (var item in rows) { item.OutlineLevel = (byte)(GroupHelper.Level((IGroup)listItem)); if (((IGroup)listItem).IsCompaund) { item.Collapsed = !((IGroup)listItem).Expand; } if (item.OutlineLevel > 0) { item.Hidden = !((IGroup)listItem).IsExpanded; } } } WriteRows(writer, rows); if (listItem is Node && map != null) { var i = 0; foreach (var item in ((Node)listItem).Nodes) { WriteMapItem(map, i++, item, 0, 0, ref mr, stringTable); } } } }
public void ExpMapLayout(SheetData sheetData, LayoutColumn map, int scol, int srow, out int mcol, out int mrow, LayoutList list, object listItem, StringKeyList stringTable) { int tws = map.GetWithdSpan(); //int ths = tool.LayoutMapTool.GetHeightSpan(map); mrow = srow; mcol = scol; Row temp = null; for (int i = 0; i < map.Count; i++) { var item = map[i]; if (!item.Visible) { continue; } map.GetVisibleIndex(item, out int c, out int r); c += scol; r += srow; if (item.Count > 0) { ExpMapLayout(sheetData, item, c, r, out c, out r, list, listItem, stringTable); } else { object celldata = ((LayoutColumn)item).Text; if (list != null) { object val = list.ReadValue(listItem, (ILayoutCell)item); celldata = list.FormatValue(listItem, val, (ILayoutCell)item); if (val is decimal && decimal.TryParse(celldata.ToString(), out decimal dval)) { celldata = val; } } Cell cell = GetCell(celldata, c, r, celldata is decimal ? 3U : 6U, stringTable); if (list == null) { cell.StyleIndex = 7; GetColumn(sheetData, c + 1, item.Width); } if (temp == null || temp.RowIndex != r) { temp = GetRow(sheetData, r, mrow >= r); } temp.Append(cell); int ws = map.GetRowWidthSpan(item.Row); if (tws > ws) { MergeCell mcell = new MergeCell() { Reference = new CellRange(c, r, c + tws - ws, r).ToString() }; GetMergeCells(sheetData.Parent).Append(mcell); } int hs = map.GetRowHeightSpan(item.Row, true); if (hs > 1) { MergeCell mcell = new MergeCell() { Reference = new CellRange(c, r, c, r + hs - 1).ToString() }; GetMergeCells(sheetData.Parent).Append(mcell); } } if (r > mrow) { mrow = r; } if (c > mcol) { mcol = c; } } }