2016-06-17 11 views
1

を示し、Iは空として完全に第を取得し、なぜならソートが動作しないことの。 html_tableにソート機能がないため、テーブルを変更します。 コードはのMoodle flexible_tableはムードル</strong><strong>に<strong>flexible_table</strong>に<strong>HTML_TABLE</strong>を変更した後、空の最初の行

ob_start(); 
      $table = new flexible_table('Cars'); 
      $table->define_baseurl(new moodle_url("/blocks/cars/view.php")); 
       $table->define_columns(array(
        'carname', 
        'carnumberplate', 
        'carhiredate', 
        'city', 
        'actions', 
       )); 
      $table->define_headers(array(
        get_string('carname', 'block_cars'), 
        get_string('carnumberplate', 'block_cars'), 
        get_string('carhiredate', 'block_cars'), 
        get_string('city', 'block_cars'), 
        get_string('actions') 
       )); 
      $table->sortable(true, 'cars'); 
      $table->collapsible(false); 

      $table->set_attribute('cellspacing', '0'); 
      $table->set_attribute('id', 'view-block-cars'); 
      $table->set_attribute('class', 'generaltable'); 
      $table->setup(); 
      // Add one blank line 
      $table->add_data(NULL); 

      $strdateformat = get_string('strftimedate'); 
      $strtimeformat = get_string('strftimetime'); 
      foreach ($cars as $car) { 
        $datestart = userdate($car->starttime, $strdateformat); 
        $dateend = userdate($car->endtime, $strdateformat); 
        $timestart = userdate($car->starttime, $strtimeformat); 
        $timeend = userdate($car->endtime, $strtimeformat); 

        $date = $datestart; 
        if ($datestart != $dateend) { 
         $date .= ' - '.$dateend; 
        } 
        $time = $timestart.' - '.$timeend; 

        $actions = array(
         html_writer::link($car->get_view_url(), get_string('view')), 
        ); 
        $actions = implode(' | ', $actions); 

        $row = array(
         format_string($car->carname), 
         format_string($car->platenumber), 
         $date, 
         format_string($car->city), 
         $actions, 
        ); 
        $table->add_data($row); 
      } 
      $table->finish_html(); 
      $out .= ob_get_clean(); 

     return $out; 

私が逃しているものは何ですか?

答えて

関連する問題