Laravel Chumper datatables.net

时间:2014-03-11 19:46:29

标签: laravel laravel-4 datatables

我是laravel的新手,想要使用datatables.net。我想在我的项目中使用chumper datatables.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',
                     )
                 );

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

1 个答案:

答案 0 :(得分:0)

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

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

使用getIndex()方法进行处理。