Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Search Datatables-如何对datatable显示的内容和数据库进行单独搜索?_Search_Server_Datatables - Fatal编程技术网

Search Datatables-如何对datatable显示的内容和数据库进行单独搜索?

Search Datatables-如何对datatable显示的内容和数据库进行单独搜索?,search,server,datatables,Search,Server,Datatables,我在MVC Codeigniter 3框架中使用datatables,并带有服务器端选项,我在每个列的标题中都有一个搜索字段,通过向返回信息的数据库查询发送对这些字段的搜索来完成对这些字段的搜索 Jquery var table = $('#datatable_serv').DataTable({ "responsive": true, "processing": true, "serverSide": true, "fix

我在MVC Codeigniter 3框架中使用datatables,并带有服务器端选项,我在每个列的标题中都有一个搜索字段,通过向返回信息的数据库查询发送对这些字段的搜索来完成对这些字段的搜索

Jquery

var table = $('#datatable_serv').DataTable({
"responsive": true,
"processing": true, 
"serverSide": true,
"fixedHeader": true,
//"fixedColumns": true,
//"autowidth": true,
    "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "Todos"]],
    "ajax": {
    "url": mostrarcontenido,//url php server
    "type": "POST",
    "data": function ( data ) {
      data.searchidpedido = $('#id_pedido').val();
      data.searchnum = $('#nºfact').val();
      data.searchfecha = $('#fecha').val();
      data.searchreferencia = $('#referencia').val();
      data.searchproducto = $('#producto').val();
      data.searchcantidad = $('#cantidad').val();
      data.searchpreciocosto = $('#preciocosto').val();
      data.searchtotalsiniva = $('#totalsiniva').val();
      data.searchtranspo = $('#transpo').val();
      data.searchcomi = $('#comi').val();
      data.searchbenefi = $('#benefi').val();
    }
},
关键是有3个字段,数据不在数据库中,而是在显示信息时计算出来的

以下是字段搜索: view.html

<thead id="principal">
              <tr style="background: #a34590; color: white; text-shadow: 1px 1px 1px #000;">
                <th style="width:10%">Id_pedido</th>
                <th style="width:10%">NºFact</th>
                <th style="width:10%">Fecha</th>
                <th style="width:10%">Referencia</th>
                <th style="width:10%">Producto</th>
                <th style="width:10%">Cantidad</th>
                <th style="width:10%">Precio Costo</th>
                <th style="width:10%">Total Sin Iva</th>
                <th style="width:10%">Transpo</th>
                <th style="width:10%">Trans Costo</th><!--independent search database-->
                <th style="width:10%">Comi</th>
                <th style="width:10%">Benefi</th>
                <th style="width:10%">Trans</th><!--independent search database-->
                <th style="width:10%">Método de Pago</th>
                <th style="width:10%" class="botones">Edición</th>
              </tr>
            </thead>
所以我想知道的是,我是如何独立于其他字段来搜索这三个字段的,这样当我在其中一个字段中搜索时,它会查看数据表中已经显示的内容,而不是发送查询

    <th style="padding:0 !important;"><input type="text" class="column_search" id="id_pedido" placeholder="Buscar Id_pedido"></th>
if( isset($_POST['start']) && isset($_POST['draw']) && isset($_POST['search']) && isset($_POST['length']) && isset($_POST['order']) ){   
     $draw = intval($this->input->post("draw"));
     //$search = $_POST["search"]["value"];
     $search= $this->input->post("search");
     $search = $search['value'];
     $length = $_POST["length"];
     $start = $_POST['start'];
     $order = $_POST["order"];
  }
search_array = array(
    'id_order' => $this->input->post("searchpedido"),
    'o.invoice_number' => $this->input->post("searchnum"),
    'o.date_add'=> $this->input->post("searchfecha"),
    'o.reference'=> $this->input->post("searchreferencia"),
    'd.product_name'=> $this->input->post("searchproducto"),
    'd.product_quantity'=> $this->input->post("searchcantidad"),
    'd.total_price_tax_excl'=> $this->input->post("searchtotalsiniva"),
    'tp.precio_transporte'=> $this->input->post("transpo"),
  );

$output = array(
    "draw"                =>     intval($_POST["draw"]),
    "recordsTotal"        =>     $this->model_side_server->serv_side_total_records($search, $search_array, $order, $start, $length, $order_column),
    "recordsFiltered"     =>     $this->model_side_server->serv_side_records_filter($search, $search_array, $order, $start, $length, $order_column),
    "data"                =>     $data
  );