phalconphp:select选项value post-in-table using datatable

bybem2ql  于 2021-06-19  发布在  Mysql
关注(0)|答案(0)|浏览(159)

我在获取字段中的值时遇到问题,我正在使用datatable作为我的表。
我的错误是,所选的值没有在表中过帐。
这是我的密码。。。注意:我使用的是phalocon php,用于phalocon的datatable api。
这是我的控制器:

public function orderWalkinAction() 
{
    $this->view->disable();
    if($this->request->isPost()) {
        $arr = array();
        $dropdown_id = $this->request->getPost('dropdown_id', 'striptags');
        $select_orderitems_query = Medics::find(
            [
                "conditions" => "medID = :id: AND status = 'ACTIVE'",
                "bind" => 
                [ 
                    "id" => $dropdown_id,
                ]
            ]
        );
            foreach ($select_orderitems_query as $data_orderItem) {
                $orderitem_medID        = $data_orderItem->medID;
                $orderitem_code         = $data_orderItem->itemcode;
                $orderitem_name         = $data_orderItem->itemname;
                $orderitem_brand        = $data_orderItem->itembrand;
                $orderitem_quan         = $data_orderItem->itemquan;
                $orderitem_price        = $data_orderItem->itemprice;
                $orderitem_totalprice   = $data_orderItem->totalPrice; 

                $arr[] = array(
                    "itemcode"  => $orderitem_code,
                    "itemname"  => $orderitem_name."-".$orderitem_brand,
                    "itemquan"  => $orderitem_quan,
                    "itemprice" => $orderitem_price,
                    "total"     => $orderitem_totalprice,
                    "action"    => "<button class='btn btn-danger' id='orderRecord-delete' data-id='".$orderitem_medID."'><i class='fa fa-trash'></i></button>"
                ); 
            }

        $dataTables = new DataTable();
        $dataTables->fromArray($arr)->sendResponse();
    }

}

这是我的js

$(document).on('change', '#items', function(e) {
    e.preventDefault();
    var dropdown_val = $(this).val();
    if(dropdown_val != null) 
    {
        //Table For Order Items
        $('#order_tbl').DataTable({
            processing: true,
            deferRender: true,
            ajax: {
                        url: '/HPsys/walkin/orderWalkin',
                        method: 'POST',
                        data: { dropdown_id : dropdown_val }
                    },
            columns: [
                { data : "itemcode" },
                { data : "itemname" },
                { data : "itemquan" },
                { data : "itemprice" },
                { data : "total" },
                { data : "action" },
            ]
        });
    } 
    else 
    {

    }
});

这是我的观点

<select class="form-control" id="items">
                <option value="">-- Select Item --</option>
            </select>
            <hr>
            <h2 class="text-center">Order Details </h2>
            <table class="table" id="order_tbl">
                <thead>
                    <tr>
                        <th>Item Code</th>
                        <th>Item Name</th>
                        <th>Quantity</th>
                        <th>Price</th>
                        <th>Total</th>
                        <th>Action</th>
                    </tr>
                </thead>

            </table>

如果有vlog/教程/或任何建议,请随时评论,我真的很感激。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题