예제 #1
0
 /**
  *
  * Check in which format data should be returned to the grid based on dataType property
  * Add the appropriate headers and echo the result
  * @param string $response can be xml or json
  */
 protected function _gridResponse($response)
 {
     if ($this->dataType == "xml") {
         if (isset($response->records)) {
             $response->rows["records"] = $response->records;
             unset($response->records);
         }
         if (isset($response->total)) {
             $response->rows["total"] = $response->total;
             unset($response->total);
         }
         if (isset($response->page)) {
             $response->rows["page"] = $response->page;
             unset($response->page);
         }
         if (stristr($_SERVER["HTTP_ACCEPT"], "application/xhtml+xml")) {
             header("Content-type: application/xhtml+xml;charset=", $this->encoding);
         } else {
             header("Content-type: text/xml;charset=" . $this->encoding);
         }
         echo jqGridUtils::toXml($response, 'root', null, $this->encoding, $this->xmlCDATA);
     } else {
         if ($this->dataType == "json") {
             header("Content-type: text/x-json;charset=" . $this->encoding);
             if (function_exists('json_encode') && strtolower($this->encoding) == 'utf-8') {
                 echo json_encode($response);
             } else {
                 echo jqGridUtils::encode($response);
             }
         }
     }
 }