,fields: ['id','fullname','username','email', 'password','extended:{groupid}', 'menu']
This question has been answered by goldsky. See the first response.
public function prepareRow(xPDOObject $object){
$objectArray = $object->toArray('', false, true);
// dump the output to error log to figure out the original result first
// $this->modx->log(modX::LOG_LEVEL_ERROR, __LINE__ . ': $objectArray['extended'] ' . print_r($objectArray['extended'], 1));
// if it's in JSON, decode it first
$extended = json_decode($objectArray['extended'], 1);
// otherwise, just create a new key to feed Javascript's field
$objectArray['groupid'] = $extended['groupid'];
return $objectArray;
},fields: ['id','fullname','username','email', 'password','groupid', 'menu']