【问题标题】:Laravel Chumper datatables.netLaravel Chumper datatables.net
【发布时间】:2014-03-11 19:46:29
【问题描述】:

我是 laravel 的新手,想使用 datatables.net。我想在我的项目中使用chumperdatatables.net?安装后。如何在服务器端(sAjaxSource)使用或更新此代码?

    oTable_categories =$('#showCategories').dataTable({
        "bLengthChange": false,
        "iDisplayLength": 6,                              
        "bScrollCollapse": true,      
        "bJQueryUI": true,
        "bAutoWidth": false,
        "sAjaxSource": "server_processing.php",
        "sPaginationType": "full_numbers",
        "bProcessing": true,

        "fnDrawCallback": function() {
                    clickRowHandler_categories();
            },   
        "fnServerParams": function ( aoData ) {
          aoData.push(
                         {"name": "id"   ,     "value": "id" },        
                         {"name": "title"   ,  "value": "title" },
                         {"name": "join"   ,   "value": "" },
                         {"name": "action"   , "value": "categories" }
          )}
        });  
        function clickRowHandler_categories() {
            $('#showCategories tbody tr').bind('click', function () {
                var aData = oTable_categories.fnGetData( this );
                if ( aData == null ) return false;
                iId_categories = aData[0];
            });
        }

我必须定义新的路线,例如:

Route::controller(
            'mediaManagment','mediaManagmentController',
                array(
                        'getIndex'               => 'mediaManagment.index',
                        'postUpdate'             => 'mediaManagment.update',
                     )
                 );

我不知道如何使用它。 谢谢

【问题讨论】:

    标签: laravel laravel-4 datatables


    【解决方案1】:

    在这里,"sAjaxSource": "server_processing.php" 应该包含您的控制器的url,它正在发送更多/分页数据/记录/模型,因此请使用mediaManagment,因为此URL 将调用getIndex() 方法。所以,使用这样的东西:

    "sAjaxSource": "mediaManagment" // http://example.com/mediaManagment
    

    在您的 getIndex() 方法中进行处理。

    【讨论】:

    • in mediaManagmentController@index 我必须使用 ajax 函数或仅使用 return View::make()
    • 这应该返回ajax request的内容,所以以这种方式实现它。
    猜你喜欢
    • 2020-09-12
    • 2015-07-21
    • 1970-01-01
    • 2015-04-16
    • 2014-08-28
    • 2014-10-22
    • 1970-01-01
    • 2015-07-31
    • 1970-01-01
    相关资源
    最近更新 更多