tc.setCellFactory(new Callback<TableColumn, TableCell>(){ @Override public TableCell call(TableColumn param){ return new TableCell(){ @Override public void updateItem(Object item, boolean isEmpty){ //...logic to format the text assertEquals(getText(), "20%"); } }; } });
cellScriptFunction = new TableCell(); // in this table cell I want to place the control which is returned from the javascript cellScriptFunction.Text = "<script> Vizit.Write(\"http://path/to/file.ext\", { buttons: [ \"InstantPreview\" ] }); </script>";
lastNameCol.setCellFactory(new Callback() { @Override public TableCell call(TableColumn col) { return new TableCell() { @Override public void updateItem(Boolean item, boolean empty) { if (!empty) { // Don't care about the value of item // Just look up the value of firstNameCol using // getTablePosition(), then create and populate // a ComboBox with the appropriate items and set // it as the graphic for this cell via this.setGraphic() // Add handler to ComboBox control to update data item when // selection changes } } }; } });
public static final Callback<TableColumn<?,?>, TableCell<?,?>> DEFAULT_CELL_FACTORY = new Callback<TableColumn<?,?>, TableCell<?,?>>() { @Override public TableCell<?,?> call(TableColumn<?,?> param) { return new TableCell() { @Override protected void updateItem(Object item, boolean empty) { if (item == getItem()) return; super.updateItem(item, empty); if (item == null) { super.setText(null); super.setGraphic(null); } else if (item instanceof Node) { super.setText(null); super.setGraphic((Node)item); } else { super.setText(item.toString()); super.setGraphic(null); } } }; } };
protected void AddRow(object sender, EventArgs e) { TableRow row = new TableRow(); TableCell cell = new TableCell(); aTable.Rows.Add(row); cell.Text = "Test"; row.Cells.Add(cell); row.Cells.Add(cell); row.Cells.Add(cell); row.Cells.Add(cell); row.Cells.Add(cell); row.Cells.Add(cell); }
GridView1_RowCreated(Object sender, GridViewRowEventArgs e) { //some code here LinkButton lb = new LinkButton(); lb.Text = "something"; lb.ID = "someId"; TableCell cell = new TableCell(); cell.Controls.Add(lb); e.Row.Cells.Add(cell); }
TableCell td = new TableCell(); Button button = new Button(); button.Text = "Adicionar"; button.ID = "Sub" + id; // Whatever "id" is button.Click += new EventHandler(BtnAdicionar_Click); td.Controls.Add(td);
GridView1_RowCreated(Object sender, GridViewRowEventArgs e) { LinkButton lb = new LinkButton(); lb.Text = "something"; lb.ID = "someId"; lb.OnClientClick = "javascript: return confirm('Are you sure that you want to do this and that?'); "; TableCell cell = new TableCell(); cell.Controls.Add(lb); e.Row.Cells.Add(cell); }
GridView1_RowCreated(Object sender, GridViewRowEventArgs e) { LinkButton lb = new LinkButton(); lb.Text = "something"; lb.ID = "someId"; lb.OnClientClick = "return showConfirmation('Are you sure you want to do this and that?','"+lb.ID+"'); "; TableCell cell = new TableCell(); cell.Controls.Add(lb); e.Row.Cells.Add(cell); }
<asp:Button ID="button1" runat="server" OnClick="AddRow" /> <asp:Table id="aTable" name="aTable" runat="server"> <asp:TableHeaderRow> <asp:TableHeaderCell>1</asp:TableHeaderCell> </asp:TableHeaderRow> </asp:Table> protected void AddRow(object sender, EventArgs e) { TableRow row = new TableRow(); TableCell cell = new TableCell(); cell.Text = "hello"; row.Cells.Add(cell); aTable.Rows.Add(row); }
// ... else if (RowType == DataControlRowType.DataRow || RowType == DataControlRowType.Footer) { _expCell = new TableCell(); _ctlExpand = new HtmlAnchor(); //_ctlExpand.HRef = "#"; -- Commenting this out worked! _ctlExpand.Attributes["onclick"] = "TglRow(this);"; _ihExp = new HtmlInputHidden(); _ihExp.ID = "e" + this.DataItemIndex.ToString(); _expCell.Controls.Add(_ctlExpand); _expCell.Controls.Add(_ihExp); } if (_expCell != null) { _expCell.Width = Unit.Pixel(20); Cells.AddAt(0, _expCell); }
int count1 = 0; TableCell tc; foreach (TableRow tr in Resource_TBL.Rows) { CheckBox cbox = new CheckBox(); cbox.ID = ""+count1; TextBox tbox = new TextBox(); tbox.ID = "textbox_" + count1; tbox.CssClass = "form-control"; tbox.Enabled = false; tbox.Attributes.Add("placeholder", "Enter Detail Here"); count1 += 1; cbox.Attributes.Add("onclick", "document.getElementById('" + tbox.ClientID + "').disabled=!this.checked;"); tr.Cells.Add(tc = new TableCell()); tc.Controls.Add(cbox); tr.Cells.Add(tc = new TableCell()); tc.Controls.Add(tbox); }
TableColumn numberCol = new TableColumn( "Number" ); numberCol.setCellFactory( new Callback<TableColumn, TableCell>() { @Override public TableCell call( TableColumn p ) { return new TableCell() { @Override public void updateItem( Object item, boolean empty ) { super.updateItem( item, empty ); setGraphic( null ); setText( empty ? null : getIndex() + 1 + "" ); } }; } });
column.setCellFactory(new Callback<TableColumn, TableCell>() { @Override public TableCell call(TableColumn param) { TableCell cell = new TableCell() { @Override public void updateItem(Object item, boolean empty) { // Don't omit this: super.updateItem(item, empty); if (item != null) { setText(item.toString()); } } }; cell.setAlignment(Pos.CENTER); return cell; } });
TableColumn firstNameCol = new TableColumn(); firstNameCol.setText("First"); firstNameCol.setCellValueFactory(new PropertyValueFactory("firstName")); firstNameCol.setCellFactory(new Callback<TableColumn, TableCell>() { @Override public TableCell call(final TableColumn param) { final TableCell cell = new TableCell() { @Override public void updateItem(Object item, boolean empty) { super.updateItem(item, empty); if (empty) { setText(null); } else { if (isEditing()) { setText(null); } else { setText(getItem().toString()); setGraphic(null); } } } }; // This way I will have context menu only for specific column cell.setContextMenu(ContextMenuBuilder.create().items(MenuItemBuilder.create().text("menu").build()).build()); return cell; } });
private TableRow rawRow(Object... args) { List<TableCell> cells = new ArrayList<>(); for (Object a : args) { cells.add(new TableCell().setV(a)); } return new TableRow().setF(cells); }
private QueryResponse createResponseContainingTestData() { TableCell field1 = new TableCell(); field1.setV("abc"); TableCell field2 = new TableCell(); field2.setV("2"); TableCell field3 = new TableCell(); field3.setV("testing BigQuery matcher."); TableRow row = new TableRow(); row.setF(Lists.newArrayList(field1, field2, field3)); QueryResponse response = new QueryResponse(); response.setJobComplete(true); response.setRows(Lists.newArrayList(row)); response.setTotalRows(BigInteger.ONE); return response; } }
Callback<TableColumn<Person, String>, TableCell<Person, String>> accCellFactory = new Callback<TableColumn<Person, String>, TableCell<Person, String>>() { @Override public TableCell call(TableColumn p) { TitledPane t1 = new TitledPane("T1", new Button("B1")); TitledPane t2 = new TitledPane("T2", new Button("B2")); TitledPane t3 = new TitledPane("T3", new Button("B3")); Accordion accordion = new Accordion(); accordion.getPanes().addAll(t1, t2, t3); TableCell tc = new TableCell(); tc.setGraphic(accordion); return tc; } };
@Test public void testDecodeEncodeEqual() throws Exception { BigQueryInsertError value = new BigQueryInsertError( new TableRow().setF(Collections.singletonList(new TableCell().setV("Value"))), new TableDataInsertAllResponse.InsertErrors() .setIndex(0L) .setErrors( Collections.singletonList( new ErrorProto() .setReason("a Reason") .setLocation("A location") .setMessage("A message") .setDebugInfo("The debug info"))), new TableReference() .setProjectId("dummy-project-id") .setDatasetId("dummy-dataset-id") .setTableId("dummy-table-id")); CoderProperties.coderDecodeEncodeEqual(TEST_CODER, value); } }