I found solution
My problem was that I did not know that for the root items in treegrid ParentRowId = ‘0’. It is assigned by default at treegrid initialization.
I found it in the source code of treegrid.
Now both my questions may be easily solved if to take into account that ParentRowId = ‘0’:
var RootItemsIds = treegrid.getSubItems(‘0’);
var AllItemsIds = treegrid.getAllSubItems(‘0’);
Get a guaranteed answer from DHTMLX technical support team
under the most suitable support plan