2017-05-05 7 views
1

stwe/DatatablesBundle을 사용하여 생성 한 테이블의 행을 어떻게 색칠 할 수 있습니까? status.id === 1 일 때 녹색으로 표시되는 전체 선 (적절한 클래스 추가)과 같은 것을 얻고 싶습니다. status.id == 2 일 때 녹색으로 표시됩니다. 2. LineFormatter (https://github.com/stwe/DatatablesBundle/blob/v0.13/Resources/doc/lineFormatter.md)를 사용하려고합니다. 콜백. status.status_id 열은 보이지 않습니다 (데이터베이스의 status.name과 관련이 있습니다).stwe/DatatablesBundle을 사용하여 생성 한 테이블의 행을 어떻게 색칠 할 수 있습니까?

public function buildDatatable(array $options = array()) 
{ 

    $this->features->set(array(
     'auto_width' => true, 
     'defer_render' => false, 
     'info' => true, 
     'jquery_ui' => false, 
     'length_change' => true, 
     'ordering' => true, 
     'paging' => true, 
     'processing' => true, 
     'scroll_x' => false, 
     'scroll_y' => '', 
     'searching' => true, 
     'state_save' => false, 
     'delay' => 0, 
     'extensions' => array(), 
     'highlight' => false, 
     'highlight_color' => 'red' 
    )); 

    $this->ajax->set(array(
     'url' => $this->router->generate('proposal_results'), 
     'type' => 'GET', 
     'pipeline' => 0 
    )); 

    $this->options->set(array(
     'display_start' => 0, 
     'defer_loading' => -1, 
     'dom' => 'lfrtip', 
     'length_menu' => array(10, 25, 50, 100), 
     'order_classes' => true, 
     'order' => array(array(0, 'asc')), 
     'order_multi' => true, 
     'page_length' => 10, 
     'paging_type' => Style::FULL_NUMBERS_PAGINATION, 
     'renderer' => '', 
     'scroll_collapse' => false, 
     'search_delay' => 0, 
     'state_duration' => 7200, 
     'stripe_classes' => array(), 
     'class' => Style::BOOTSTRAP_3_STYLE, 
     'individual_filtering' => false, 
     'individual_filtering_position' => 'head', 
     'use_integration_options' => true, 
     'force_dom' => false, 
     'row_id' => 'id' 
    )); 

    $this->columnBuilder 
     ->add('id', 'column', array(
      'title' => 'ID', 
     )) 
     ->add('client.name', 'column', array(
      'title' => 'Client name', 
     )) 
     ->add('client.surname', 'column', array(
      'title' => 'Client surname', 
     )) 
     ->add('client.code', 'column', array(
      'title' => 'Client Code', 
     )) 
     ->add('date_add', 'datetime', array(
      'title' => 'Date added', 
      'date_format' => 'LLL' 
     )) 
     ->add('status.name', 'column', array(
      'title' => 'Status', 
     )); 
//   ->add('status.status_id', 'column', array(
//    'title' => 'Status Status_id', 
//   )) 
} 
+0

알고 싶습니다. –

답변

0

당신은 Datatable.php 파일에 getLineFormatter을 추가하여이 문제를 해결 할 수 있습니다 :

이 내 Datatable.php 파일이 위해서는

public function getLineFormatter() 
{ 
    $formatter = function ($line) { 
     if($line['status_id'] == 1) { 
      $line['DT_RowClass'] = 'class_name'; 
     } 
     return $line; 
    }; 
    return $formatter; 
} 

은 추가 할 필요가 작동하려면 status_id를 열 또는 숨겨진 열로 나타냅니다.