Function getValueFromElem

  • Read the value from 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 for a checkbox, a value of true, false, or null is returned if the element is checked, unchecked, or indeterminate. For datetime input control a numerical value is assumed, etc.

    Common use case: store the new user input in a change event handler:

      change: (e) => {
    const tree = e.tree;
    const node = e.node;
    // Read the value from the input control that triggered the change event:
    let value = tree.getValueFromElem(e.element);
    // and store it to the node model (assuming the column id matches the property name)
    node.data[e.info.colId] = value;
    },

    Parameters

    • elem: HTMLElement

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

    • coerce: boolean = false

      pass true to convert date/time inputs to Date.

    Returns any

    the value