Function setValueToElem

  • Set the value of an HTML input element.

    If a <span class="wb-col"> is passed, the first child input is used. Depending on the target element type, value is interpreted accordingly. For example a checkbox is set to checked, unchecked, or indeterminate if the value is truethy, falsy, or null. For datetime input control a numerical value is assumed, etc.

    Common use case: update embedded input controls in a render event handler:

      render: (e) => {
    // e.node.log(e.type, e, e.node.data);

    for (const col of Object.values(e.renderColInfosById)) {
    switch (col.id) {
    default:
    // Assumption: we named column.id === node.data.NAME
    util.setValueToElem(col.elem, e.node.data[col.id]);
    break;
    }
    }
    },

    Parameters

    • elem: HTMLElement

      <input> or <select> element Also a parent span.wb-col is accepted.

    • value: any

      a value that matches the target element.

    Returns void