Search Row and Cell

조건에 맞는 그리드행을 순차적으로 찾아가는 Grid다.

1. Search Row

- Case Sensitive : 체크시 대,소문자를 구분한다.
- Partial Match : 체크시 France의 경우 ran 단어의 부분만 맞아도 검색이 가능하게한다.
- Wrap : 체크시 찾으려는 단어를 끝까지 찾고, 처음부터 돌아가서 다시 해당하는 단어를 찾는다.
1-1 '국가'로 검색

국가 행 중에서 'France' 에 해당하는 Row를 검색한다.
Code-1
public void run(final GridView grid) throws Exception { //Utils.input(grid.getContext(), "Input here", "Input Dlg"); form.getItem("industry").visible = false; new FormDialog().show(grid.getContext(), form, new FormDialog.OnCloseListener() { @Override public void onClose(Context ctx, Form form) { Map data = form.getData(); System.out.println(data); boolean caseSensitive = (boolean)data.get("case"); boolean partialMatch = (boolean)data.get("match"); SearchOptions options = new SearchOptions().setCaseSensitive(caseSensitive).setPartialMatch(partialMatch); boolean wrap = (boolean)data.get("wrap"); int r = grid.focusedRow() + 1; String v = Value.toStr(data.get("country")); r = grid.searchRow("country", v, options, r, wrap, true); if (r >= 0) { try { m_ds.clearRowTags(null, null); m_ds.setRowTag(grid.getItem(r).dataIndex(), "#found"); } catch (Throwable ex) { ex.printStackTrace(); Utils.alert(ctx, ex.getMessage()); } } } }); }
let grid = ($0 as! GridComponent).gridView as! GridView let ds = grid.dataSource! FormDialog().show(form: self.form, callback: { (form) in let data = form.getData() print(data) let caseSensitive = data["case"] as! Bool let partialMath = data["match"] as! Bool let wrap = data["wrap"] as! Bool let options = SearchOptions() let r = grid.focusedRow + 1 let v = Value.toStr(data["country"]) options.isCaseSensitive = caseSensitive options.isPartialMatch = partialMath if let r = grid.searchRow(field: "country", value: v, options: options, startRow: r, wrap: wrap, select: true) { do { try ds.clearRowTags() try ds.setRowTag(row: grid.getItem(at: r)!.dataIndex, tag: "#found") } catch { print(error) Utils.alert(error) } } })


1-2 '국가'로 다음찾기

국가 행 중에서 'France' 에 해당하는 Row를 계속해서 찾아준다.

Code-2
public void run(final GridView grid) throws Exception { Map data = form.getData(); boolean caseSensitive = (boolean)data.get("case"); boolean partialMatch = (boolean)data.get("match"); SearchOptions options = new SearchOptions().setCaseSensitive(caseSensitive).setPartialMatch(partialMatch); boolean wrap = (boolean)data.get("wrap"); int r = grid.focusedRow() + 1; String v = Value.toStr(data.get("country")); r = grid.searchRow("country", v, options, r, wrap, true); if (r >= 0) { try { m_ds.clearRowTags(null, null); m_ds.setRowTag(grid.getItem(r).dataIndex(), "#found"); } catch (Throwable ex) { ex.printStackTrace(); Utils.alert(grid.getContext(), ex.getMessage()); } } } }
let grid = ($0 as! GridComponent).gridView as! GridView let ds = grid.dataSource! let data = self.form.getData() let caseSensitive = data["case"] as! Bool let partialMath = data["match"] as! Bool let wrap = data["wrap"] as! Bool let options = SearchOptions() let r = grid.focusedRow + 1 let v = Value.toStr(data["country"]) options.isCaseSensitive = caseSensitive options.isPartialMatch = partialMath if let r = grid.searchRow(field: "country", value: v, options: options, startRow: r, wrap: wrap, select: true) { do { try ds.clearRowTags() try ds.setRowTag(row: grid.getItem(at: r)!.dataIndex, tag: "#found") } catch { print(error) Utils.alert(error) } }


1-3 '국가'와 '사업분야'로 검색

입력한 행에서 국가와 사업분야가 일치하면 다음과 같이 표시 된다.

Code-3
public void run(final GridView grid) throws Exception { //Utils.input(grid.getContext(), "Input here", "Input Dlg"); form.getItem("industry").visible = true; new FormDialog().show(grid.getContext(), form, new FormDialog.OnCloseListener() { @Override public void onClose(Context ctx, Form form) { Map data = form.getData(); System.out.println(data); boolean caseSensitive = (boolean)data.get("case"); boolean partialMatch = (boolean)data.get("match"); SearchOptions options = new SearchOptions().setCaseSensitive(caseSensitive).setPartialMatch(partialMatch); boolean wrap = (boolean)data.get("wrap"); int r = grid.focusedRow() + 1; String country = Value.toStr(data.get("country")); String industry = Value.toStr(data.get("industry")); r = grid.searchRow(new String[] { "country", "industry" }, new Object[] { country, industry }, options, r, wrap, true); if (r >= 0) { try { m_ds.clearRowTags(null, null); m_ds.setRowTag(grid.getItem(r).dataIndex(), "#found2"); } catch (Throwable ex) { ex.printStackTrace(); Utils.alert(ctx, ex.getMessage()); } } } }); }
let grid = ($0 as! GridComponent).gridView as! GridView let ds = grid.dataSource! FormDialog().show(form: self.form, callback: { (form) in let data = form.getData() print(data) let caseSensitive = data["case"] as! Bool let partialMath = data["match"] as! Bool let wrap = data["wrap"] as! Bool let options = SearchOptions() let r = grid.focusedRow + 1 let country = Value.toStr(data["country"]) let industry = Value.toStr(data["industry"]) options.isCaseSensitive = caseSensitive options.isPartialMatch = partialMath if let r = grid.searchRow(fields: ["country", "industry"], values: [country, industry], options: options, startRow: r, wrap: wrap, select: true) { do { try ds.clearRowTags() try ds.setRowTag(row: grid.getItem(at: r)!.dataIndex, tag: "#found2") } catch { print(error) Utils.alert(error) } } })


1-4 '국가'와 '사업분야'로 다음 찾기

입력한 행에서 국가와 사업분야가 일치하는 행을 계속해서 찾아준다.

Code-4
public void run(final GridView grid) throws Exception { Map data = form.getData(); boolean caseSensitive = (boolean)data.get("case"); boolean partialMatch = (boolean)data.get("match"); SearchOptions options = new SearchOptions().setCaseSensitive(caseSensitive).setPartialMatch(partialMatch); boolean wrap = (boolean)data.get("wrap"); int r = grid.focusedRow() + 1; String country = Value.toStr(data.get("country")); String industry = Value.toStr(data.get("industry")); r = grid.searchRow(new String[] { "country", "industry" }, new Object[] { country, industry }, options, r, wrap, true); if (r >= 0) { try { m_ds.clearRowTags(null, null); m_ds.setRowTag(grid.getItem(r).dataIndex(), "#found2"); } catch (Throwable ex) { ex.printStackTrace(); Utils.alert(grid.getContext(), ex.getMessage()); } } }
let grid = ($0 as! GridComponent).gridView as! GridView let ds = grid.dataSource! let data = self.form.getData() let caseSensitive = data["case"] as! Bool let partialMath = data["match"] as! Bool let wrap = data["wrap"] as! Bool let options = SearchOptions() let r = grid.focusedRow + 1 let country = Value.toStr(data["country"]) let industry = Value.toStr(data["industry"]) options.isCaseSensitive = caseSensitive options.isPartialMatch = partialMath if let r = grid.searchRow(fields: ["country", "industry"], values: [country, industry], options: options, startRow: r, wrap: wrap, select: true) { do { try ds.clearRowTags() try ds.setRowTag(row: grid.getItem(at: r)!.dataIndex, tag: "#found2") } catch { print(error) Utils.alert(error) } }



1-5. Search Row 실행화면

2. Search Cell

2-1 '국가'로 검색

국가 행 중에서 'France' 에 해당하는 Cell을 검색한다.
Code-5
public void run(final GridView grid) throws Exception { form.getItem("country").visible = true; form.getItem("key").visible = false; new FormDialog().show(grid.getContext(), form, new FormDialog.OnCloseListener() { @Override public void onClose(Context ctx, Form form) { Map data = form.getData(); System.out.println(data); boolean caseSensitive = (boolean)data.get("case"); boolean partialMatch = (boolean)data.get("match"); SearchOptions options = new SearchOptions().setCaseSensitive(caseSensitive).setPartialMatch(partialMatch); boolean wrap = (boolean)data.get("wrap"); int r = m_result != null ? m_result.rowIndex + 1 : grid.focusedRow(); String v = Value.toStr(data.get("country")); m_result = grid.searchCell("colCountry", v, options, r, 0, wrap, true); if (m_result != null) { try { m_ds.clearRowTags(null, null); m_ds.setRowTag(m_result.dataRow, "#found_1"); } catch (Throwable ex) { ex.printStackTrace(); Utils.alert(ctx, ex.getMessage()); } } } }); }
let grid = ($0 as! GridComponent).gridView as! GridView let ds = grid.dataSource! self.form.getItem(id: "country")?.visible = true self.form.getItem(id: "key")?.visible = false FormDialog().show(form: self.form, callback: { (form) in let data = form.getData() print(data) let caseSensitive = data["case"] as! Bool let partialMath = data["match"] as! Bool let wrap = data["wrap"] as! Bool let options = SearchOptions() let r = self.m_result != nil ? self.m_result!.rowIndex + 1 : grid.focusedRow let v = Value.toStr(data["country"]) options.isCaseSensitive = caseSensitive options.isPartialMatch = partialMath self.m_result = grid.searchCell(columnName: "colCountry", value: v, options: options, startRowIndex: r, startColumnIndex: 0, wrap: wrap, select: true) if self.m_result != nil { do { try ds.clearRowTags() try ds.setRowTag(row: self.m_result.dataRow, tag: "#found_1") } catch { print(error) Utils.alert(error) } } })



2-2 '국가'로 다음 찾기

국가 행 중에서 'France' 에 해당하는 Cell을 계속해서 찾아준다.
Code-6
public void run(final GridView grid) throws Exception { Map data = form.getData(); boolean caseSensitive = (boolean)data.get("case"); boolean partialMatch = (boolean)data.get("match"); SearchOptions options = new SearchOptions().setCaseSensitive(caseSensitive).setPartialMatch(partialMatch); boolean wrap = (boolean)data.get("wrap"); int r = m_result != null ? m_result.rowIndex + 1 : grid.focusedRow(); String v = Value.toStr(data.get("country")); m_result = grid.searchCell("colCountry", v, options, r, 0, wrap, true); if (m_result != null) { try { m_ds.clearRowTags(null, null); m_ds.setRowTag(m_result.dataRow, "#found_1"); } catch (Throwable ex) { ex.printStackTrace(); Utils.alert(grid.getContext(), ex.getMessage()); } } }
let grid = ($0 as! GridComponent).gridView as! GridView let ds = grid.dataSource! let data = self.form.getData() let caseSensitive = data["case"] as! Bool let partialMath = data["match"] as! Bool let wrap = data["wrap"] as! Bool let options = SearchOptions() let r = self.m_result != nil ? self.m_result!.rowIndex + 1 : grid.focusedRow let v = Value.toStr(data["country"]) options.isCaseSensitive = caseSensitive options.isPartialMatch = partialMath self.m_result = grid.searchCell(columnName: "colCountry", value: v, options: options, startRowIndex: r, startColumnIndex: 0, wrap: wrap, select: true) if self.m_result != nil { do { try ds.clearRowTags() try ds.setRowTag(row: self.m_result.dataRow, tag: "#found_1") } catch { print(error) Utils.alert(error) } }



2-3 '국가'컬럼들에서 검색

국가 컬럼 중에서 'Italy' 에 해당하는 Cell을 찾아준다.
Code-7
public void run(final GridView grid) throws Exception { form.getItem("country").visible = true; form.getItem("key").visible = false; new FormDialog().show(grid.getContext(), form, new FormDialog.OnCloseListener() { @Override public void onClose(Context ctx, Form form) { Map data = form.getData(); boolean caseSensitive = (boolean)data.get("case"); boolean partialMatch = (boolean)data.get("match"); SearchOptions options = new SearchOptions().setCaseSensitive(caseSensitive).setPartialMatch(partialMatch); boolean wrap = (boolean)data.get("wrap"); int r = grid.focusedRow(); String country = Value.toStr(data.get("country")); String[] cols = new String[] { "colCountry", "colCountry2", "colCountry3" }; int startRow = m_result2 != null ? m_result2.rowIndex : r; int colStart = m_result2 != null ? m_result2.columnIndex + 1 : 0; m_result2 = grid.searchCell(cols, country, options, startRow, colStart, wrap, true); if (m_result2 != null) { try { m_ds.clearRowTags(null, null); String tag; switch (m_result2.column.getName()) { case "colCountry2": tag = "#found_2"; break; case "colCountry3": tag = "#found_3"; break; default: tag = "#found_1"; break; } m_ds.setRowTag(m_result2.dataRow, tag); } catch (Throwable ex) { ex.printStackTrace(); Utils.alert(ctx, ex.getMessage()); } } } }); }
let grid = ($0 as! GridComponent).gridView as! GridView let ds = grid.dataSource! self.form.getItem(id: "country")?.visible = true self.form.getItem(id: "key")?.visible = false FormDialog().show(form: self.form, callback: { (form) in let data = form.getData() print(data) let caseSensitive = data["case"] as! Bool let partialMath = data["match"] as! Bool let wrap = data["wrap"] as! Bool let options = SearchOptions() let r = grid.focusedRow let v = Value.toStr(data["country"]) let cols = ["colCountry", "colCountry2", "colCountry3"] let startRow = self.m_result2 != nil ? self.m_result2!.rowIndex : r let colStart = self.m_result2 != nil ? self.m_result2!.columnIndex + 1 : 0 options.isCaseSensitive = caseSensitive options.isPartialMatch = partialMath self.m_result2 = grid.searchCell(columnNames: cols, value: v, options: options, startRowIndex: startRow, startColumnIndex: colStart, wrap: wrap, select: true) if self.m_result2 != nil { do { try ds.clearRowTags() var tag: String? switch self.m_result2.column!.name! { case "colCountry2": tag = "#found_2"; break; case "colCountry3": tag = "#found_3"; break; default: tag = "#found_1"; break; } try ds.setRowTag(row: self.m_result2.dataRow, tag: tag) } catch { print(error) Utils.alert(error) } } })



2-4 '국가'컬럼들에서 다음 찾기

국가 컬럼 중에서 'Italy' 에 해당하는 Cell을 계속해서 찾아준다.
Code-8
public void run(final GridView grid) throws Exception { Map data = form.getData(); boolean caseSensitive = (boolean)data.get("case"); boolean partialMatch = (boolean)data.get("match"); SearchOptions options = new SearchOptions().setCaseSensitive(caseSensitive).setPartialMatch(partialMatch); boolean wrap = (boolean)data.get("wrap"); int r = grid.focusedRow(); String country = Value.toStr(data.get("country")); String[] cols = new String[] { "colCountry", "colCountry2", "colCountry3" }; int startRow = m_result2 != null ? m_result2.rowIndex : r; int colStart = m_result2 != null ? m_result2.columnIndex + 1 : 0; m_result2 = grid.searchCell(cols, country, options, startRow, colStart, wrap, true); if (m_result2 != null) { try { m_ds.clearRowTags(null, null); String tag; switch (m_result2.column.getName()) { case "colCountry2": tag = "#found_2"; break; case "colCountry3": tag = "#found_3"; break; default: tag = "#found_1"; break; } m_ds.setRowTag(m_result2.dataRow, tag); } catch (Throwable ex) { ex.printStackTrace(); Utils.alert(grid.getContext(), ex.getMessage()); } } }
let grid = ($0 as! GridComponent).gridView as! GridView let ds = grid.dataSource! let data = self.form.getData() let caseSensitive = data["case"] as! Bool let partialMath = data["match"] as! Bool let wrap = data["wrap"] as! Bool let options = SearchOptions() let r = grid.focusedRow let v = Value.toStr(data["country"]) let cols = ["colCountry", "colCountry2", "colCountry3"] let startRow = self.m_result2 != nil ? self.m_result2!.rowIndex : r let colStart = self.m_result2 != nil ? self.m_result2!.columnIndex + 1 : 0 options.isCaseSensitive = caseSensitive options.isPartialMatch = partialMath self.m_result2 = grid.searchCell(columnNames: cols, value: v, options: options, startRowIndex: startRow, startColumnIndex: colStart, wrap: wrap, select: true) if self.m_result2 != nil { do { try ds.clearRowTags() var tag: String? switch self.m_result2.column!.name! { case "colCountry2": tag = "#found_2"; break; case "colCountry3": tag = "#found_3"; break; default: tag = "#found_1"; break; } try ds.setRowTag(row: self.m_result2.dataRow, tag: tag) } catch { print(error) Utils.alert(error) } }



2-5 모든 컬럼들에서 검색

모든 컬럼 중에서 'Japan' 에 해당하는 Cell을 찾아준다.
Code-9
public void run(final GridView grid) throws Exception { form.getItem("country").visible = false; form.getItem("key").visible = true; new FormDialog().show(grid.getContext(), form, new FormDialog.OnCloseListener() { @Override public void onClose(Context ctx, Form form) { Map data = form.getData(); boolean caseSensitive = (boolean)data.get("case"); boolean partialMatch = (boolean)data.get("match"); SearchOptions options = new SearchOptions().setCaseSensitive(caseSensitive).setPartialMatch(partialMatch); boolean wrap = (boolean)data.get("wrap"); int r = grid.focusedRow(); String key = Value.toStr(data.get("key")); int startRow = m_result3 != null ? m_result3.rowIndex : r; int colStart = m_result3 != null ? m_result3.columnIndex + 1 : 0; m_result3 = grid.searchCell(key, options, startRow, colStart, wrap, true); if (m_result3 != null) { try { m_ds.clearRowTags(null, null); m_ds.setRowTag(m_result3.dataRow, "#found_" + m_result3.column.getName()); } catch (Throwable ex) { ex.printStackTrace(); Utils.alert(ctx, ex.getMessage()); } } } }); }
let grid = ($0 as! GridComponent).gridView as! GridView let ds = grid.dataSource! self.form.getItem(id: "country")?.visible = false self.form.getItem(id: "key")?.visible = true FormDialog().show(form: self.form, callback: { (form) in let data = form.getData() print(data) let caseSensitive = data["case"] as! Bool let partialMath = data["match"] as! Bool let wrap = data["wrap"] as! Bool let options = SearchOptions() let r = grid.focusedRow let v = Value.toStr(data["key"]) let startRow = self.m_result3 != nil ? self.m_result3!.rowIndex : r let colStart = self.m_result3 != nil ? self.m_result3!.columnIndex + 1 : 0 options.isCaseSensitive = caseSensitive options.isPartialMatch = partialMath self.m_result3 = grid.searchCell(value: v, options: options, startRowIndex: startRow, startColumnIndex: colStart, wrap: wrap, select: true) if self.m_result3 != nil { do { try ds.clearRowTags() try ds.setRowTag(row: self.m_result3.dataRow, tag: "#found_" + (self.m_result3.column?.name)!) } catch { print(error) Utils.alert(error) } } })



2-6 모든 컬럼들에서 다음 찾기

모든 컬럼 중에서 'Japan' 에 해당하는 Cell을 계속해서 찾아준다.
Code-10
public void run(final GridView grid) throws Exception { Map data = form.getData(); boolean caseSensitive = (boolean)data.get("case"); boolean partialMatch = (boolean)data.get("match"); SearchOptions options = new SearchOptions().setCaseSensitive(caseSensitive).setPartialMatch(partialMatch); boolean wrap = (boolean)data.get("wrap"); int r = grid.focusedRow(); String key = Value.toStr(data.get("key")); int startRow = m_result3 != null ? m_result3.rowIndex : r; int colStart = m_result3 != null ? m_result3.columnIndex + 1 : 0; m_result3 = grid.searchCell(key, options, startRow, colStart, wrap, true); if (m_result3 != null) { try { m_ds.clearRowTags(null, null); m_ds.setRowTag(m_result3.dataRow, "#found_" + m_result3.column.getName()); } catch (Throwable ex) { rex.printStackTrace(); Utils.alert(grid.getContext(), ex.getMessage()); } } }
let grid = ($0 as! GridComponent).gridView as! GridView let ds = grid.dataSource! let data = self.form.getData() print(data) let caseSensitive = data["case"] as! Bool let partialMath = data["match"] as! Bool let wrap = data["wrap"] as! Bool let options = SearchOptions() let r = grid.focusedRow let v = Value.toStr(data["key"]) let startRow = self.m_result3 != nil ? self.m_result3!.rowIndex : r let colStart = self.m_result3 != nil ? self.m_result3!.columnIndex + 1 : 0 options.isCaseSensitive = caseSensitive options.isPartialMatch = partialMath self.m_result3 = grid.searchCell(value: v, options: options, startRowIndex: startRow, startColumnIndex: colStart, wrap: wrap, select: true) if self.m_result3 != nil { do { try ds.clearRowTags() try ds.setRowTag(row: self.m_result3.dataRow, tag: "#found_" + (self.m_result3.column?.name)!) } catch { print(error) Utils.alert(error) } }



2-7. Search Cell 실행화면