GridHandler::fetchRow PHP Method

fetchRow() public method

Render a row and send it to the client. If the row no longer exists then inform the client.
public fetchRow ( &$args, $request ) : JSONMessage
$args array
$request Request
return JSONMessage JSON object.
    function fetchRow(&$args, $request)
    {
        // Instantiate the requested row (includes a
        // validity check on the row id).
        $row = $this->getRequestedRow($request, $args);
        $json = new JSONMessage(true);
        if (is_null($row)) {
            // Inform the client that the row does no longer exist.
            $json->setAdditionalAttributes(array('elementNotFound' => $args['rowId']));
        } else {
            // Render the requested row
            $renderedRow = $this->renderRow($request, $row);
            $json->setContent($renderedRow);
            // Add the sequence map so grid can place the row at the correct position.
            $sequenceMap = $this->getRowsSequence($request);
            $json->setAdditionalAttributes(array('sequenceMap' => $sequenceMap));
        }
        $this->callFeaturesHook('fetchRow', array('request' => &$request, 'grid' => &$this, 'row' => &$row, 'jsonMessage' => &$json));
        // Render and return the JSON message.
        return $json;
    }

Usage Example

 /**
  * @copydoc GridHandler::fetchRow()
  */
 function fetchRow($args, $request)
 {
     $json = parent::fetchRow($args, $request);
     if ($row = $this->getRequestedRow($request, $args)) {
         $galley = $row->getData();
         if ($galley->getRemoteUrl() == '' && !$galley->getFileId()) {
             $json->setEvent('uploadFile', $galley->getId());
         }
     }
     return $json;
 }