getDSCurrent
getDSCurrent
Returns the currently selected index of a DataSet list field, based on the original (pre-sort) order.
Parameters
path(String): The path of the list field in the DataSet (e.g."ds.list")
Returns: number — the original index of the selected row, or -1 if nothing is selected or the list does not exist
Description
The index is always relative to the original data, even when sorting or filtering is applied. If you need an index based on the displayed order, see getIndexFromOrg.
:::warning Path separator
The path separator is ., not /. If you built a screen from a "stock/list"-style path, correct the path.
:::
Example
var idx = $vm.getDSCurrent("stock.list");
$log.i("현재 선택 인덱스:", idx);
// 선택된 행의 값 읽기
var cur = $vm.getDSCurrent("ds.list");
if (cur >= 0) {
var name = $vm.getDSValue("ds.list[" + cur + "].name");
$log.i("선택된 항목:", name);
}
Related
$vm.setDSCurrent(path, current)— set the currently selected index$vm.getOrgFromIndex(path, idx)— convert a display index to an original index$vm.getIndexFromOrg(path, org)— convert an original index to a display index