lib/YuiRestClient/Widget/Table.pm

NAME

YuiRestClient::Widget::Table - Handle table objects in the UI

COPYRIGHT

Copyright 2020 SUSE LLC

SPDX-License-Identifier: FSFAP

AUTHORS

QE Yam <qe-yam at suse de>

SYNOPSIS

$self->{tbl_available_devices}->select(value => $device);

DESCRIPTION

Overview

Class representing a table in the UI. It can be YTable.

{
  "class": "YTable",
  "columns": 4,
  "header": [
    "header1",
    "header2",
    "header3",
    "header4"
  ],
  "id": "test_id",
  "items": [
      {
          "labels": [
             "test.item.1",
             "",
             "",
             ""
          ],
          "selected": true
      },
      {
          "labels": [
              "test.item.2",
              "",
              "",
              ""
          ]
      }
  ],
  "items_count": 2
}

Class and object methods

select(%args) - select a row in a table

Sends action to select a row in a table. Row can be selected either by cell value in the column (first column will be used by default), or by row number directly. If both are provided, value will be used. NOTE: row number corresponds to the position of the item in the list of column values which might differ to the display order.

The %args has has the following keys:

Example: Select row with value "test.item.2" for column "header1" in table

$self->{table}->select(value => 'test.item.2', column => 'header1');

Example: Select row number 3

$self->{table}->select(row => 3);

header() - returns array with the column names

items() - returns all table items

For the example table above this function would return

(["test.item.1", "", ""],["Test.item.2", "", ""])

get_index($column) - return the index of the column

The parameter $column specifies the header string that we're looking for.