cancel
Showing results for 
Search instead for 
Did you mean: 

Edit table

Former Member
0 Kudos

Hi,

I have a table whith results from a search (findBy... or findAll - all the objects, for example list of books, or students) and I want to add edit, delete and new functions for the table. When I press the edit button the current row should become editable, for new an empty row to become editable. Is there any good step by step tutorial for this or could someone tell me how can I do this?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

First, add a new boolean attribute "readOnly" under the table's data source node "Rows" to be able to control the editability of each row.

Bind the "readOnly" property of the table column editor (e.g. InputField) to this attribute.

Create actions "EditRow", "AddRow" "DeleteRow", add a toolbar to the table with buttons assigned to these actions.

Action handlers:

onActionEditRow(...)
{
  IRowsElement row = wdContext.nodeRows().currentRowsElement();
  if (row == null)
  {
    return; // now row selected
  }
  row.setReadOnly(false); // activate row editor(s)
}

onActionAddRow(...)
{
  // add row at end
  IRowsElement row = wdContext.nodeRows().createAndAddRowsElement();
  row.setReadOnly(false);
  // make it the current row
  wdContext.nodeRows().setLeadSelection(row.index());
}

onActionDeleteRow(...)
{
  IRowsElement row = wdContext.nodeRows().currentRowsElement();
  if (row == null)
  {
    return; // now row selected
  }
  wdContext.nodeRows().removeElement(row);
}

This should give roughly the idea. Probably, you also want to use the onLeadSelect event to reset the editability of all rows except the selected one.

Armin

Answers (0)