Laravel Chumper datatables.net - laravel

i'm newbie in laravel and want to use datatables.net. i want to using chumper datatables.net in my projects? after installing that. how to use or update this code for server side (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];
});
}
i must be define new route such as :
Route::controller(
'mediaManagment','mediaManagmentController',
array(
'getIndex' => 'mediaManagment.index',
'postUpdate' => 'mediaManagment.update',
)
);
i do not know how to use that.
thanks

Here, "sAjaxSource": "server_processing.php" should contain the url of your controller which is sending more/paginated data/records/models so use the mediaManagment because this URL will invoke the getIndex() method. So, use something like this:
"sAjaxSource": "mediaManagment" // http://example.com/mediaManagment
Do the processing in your getIndex() method.

Related

Datatable Search Filter Column problem "mb_strtolower() expects parameter 1 to be string, array given"

I want to make a Prescription management system with laravel. so need to patient list. i loaded patient information in Datatable. this is loaded successfully but when i use Datatable Search Filter Column then this error message come "mb_strtolower() expects parameter 1 to be string, array given"
var table = $('#patient-data-table').DataTable( {
"processing": true,
"serverSide": true,
"paging": true,
"lengthChange": true,
"searching": true,
"ordering": true,
"info": true,
"autoWidth": false,
"aoColumnDefs": [{ "bVisible": false, "aTargets": [1] }],
"ajax": {
"url": "{{URL::to('/')}}/patientList",
"type": "GET",
"dataType": "json",
},
"columns": [
{
"render": function (data, type, JsonResultRow, meta) {
return '<img src="{{asset('patient_image')}}/'+JsonResultRow.image+'" style="height:30px; width:30px; border-radius: 30px;"/>';
}
},
{ "data": "fullName" },
{
data: {fullName : "fullName", email : "email", address : "address"},
mRender : function(data, type, full) {
return "Name: "+data.fullName+' <br> '+"Email: "+data.email+' <br> '+"Address: "+data.address;
}
},
{ "data": "contact_number" },
{ "data": "gender" },
{ "data": "Link", name: 'link', orderable: false, searchable: false}
],
"order": [[1, 'asc']]
} );
How can i solve this problem?
Try change:
{
data: {fullName : "fullName", email : "email", address : "address"},
mRender : function(data, type, full) {
return "Name: "+data.fullName+' <br> '+"Email: "+data.email+' <br> '+"Address: "+data.address;
}
},
For:
{
data: {fullName : "fullName", email : "email", address : "address"},
mRender : function(data, type, full) {
return "Name: "+data.fullName+' <br> '+"Email: "+data.email+' <br> '+"Address: "+data.address;
}
searchable: false, //add this line
},

dataTable ajax URL not working in laravel 5.0

In my application using dataTable. In that ajax URL we are using. But while running, error message showing url not found kind. But it is there in route file. Why it showing like that?
My dataTable code is,
var oTable = $('.table').DataTable({
"oLanguage": {
"sSearch": "Search all columns:"
},
searching: false,
"processing": true,
"serverSide": true,
"ajax": {
"url": "{{ URL::to('loadfeedback') }}",
"data": function (d) {
d.from_date = $('#from_date').val();
}
},
"columns": [
{"data": null},
{"data": "name"},
],
'columnDefs': [
{
"searchable": false,
"orderable": false,
"targets": 0
},
],
"fnRowCallback": function (nRow, aData, iDisplayIndex) {
var index = iDisplayIndex + 1;
$('td:eq(0)', nRow).html(index);
return nRow;
},
'iDisplayLength': 25,
"sPaginationType": "full_numbers",
"dom": 'T<"clear">lfrtip',
"order": [[0, 'desc']]
});
In routes.php
Route::get('loadfeedback', 'HomeController#loadfeedback');
In Controller.php
public function loadfeedback() {
$input = Input::all();
return Admin::loadfeedback($input);
}
What's wrong on this? And also it's working fine in my local system. After hosting only this issue found. But only this url, others are working fine.
Please help me.

Datagrid delete column with confirmation

This is my code
function GetLaminasyon() {
$('#tblLaminasyon').DataTable().destroy();
$('#tblLaminasyon').DataTable( {
"paging": false,
"ordering": false,
"info": false,
"searching":false,
"data": objLaminasyon,
"columns": [
{ "data": "Name" },
{ "data": "Amount" },
{ "data": "Price" },
{
"data": "Id",
"render": function(data,type,row) {
var actionButton = "<button type='button' id='btnDeleteLaminasyon' class='btn btn-danger'>Sil</button>";
return actionButton;
}}
]
} );
}
How can i a delete confirmation for this datatable? I tried to find the solution but i couldnt find it. thanks a lot.

aData is not fetching in fnRowCallback while using Datatables

Here is my code. I tried to alert the data in a particular row, but I keep getting undefined error.
I tried to print aData using aData.toString(), I'm getting [object] [object] as response. how do I debug the contents of aData?
My Code:
$(document).ready(function() {
var table = $('#datatable').DataTable({
processing: true,
serverSide: false,
order: [[1, 'asc']],
"aoColumnDefs": [ { "sClass": "hide_me", "aTargets": [ 0 ], visible: false } ], // first column in visible columns array gets class "hide_me"
ajax: {
url: "/getData",
dataSrc: "list"
},
columns: [
{ data : "_id"},
{ data : "user.name" },
{ data : "student.name" },
{ data : "class" },
{ data : "status" },
],
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
alert(aData.[4]);
if ( aData[4] == true )
{
$('td:eq(4)', nRow).html( '<b>On</b>' );
}
else {
$('td:eq(4)', nRow).html( '<b>Off</b>' );
}
},
responsive: true
});
});

"Cannot Convert Lambda Expression to Delegate type" Error in RavenDB query

I have a RavenDb document that looks like this:
{
"ParentId": null,
"Order": 10,
"Url": "/sandbox",
"Rows":
[
{
"InstanceId": "2771a0d7-7f3f-4854-a3ba-27f25f88a45e",
"CSSClass": null,
"Columns":
[
{
"InstanceId": "b91495f5-b770-4da7-8073-ad3bd8221ca8",
"CSSClass": null,
"Span": 3,
"CMSModuleInstanceSettings":
[
{
"$type": "ModuleHTML.Models.ModuleHTMLInstanceSettings, ModuleHTML",
"IsActive": false,
"ShowAuthor": false,
"ShowDate": false,
"ShowCommentsCount": false,
"ShowLast2Comments": false,
"CMSModuleInstanceId": 417,
"ContainerClass": "default",
"ModuleType": "ModuleHTML",
"DisplayType": "Summary"
},
{
"$type": "ModuleHTML.Models.ModuleHTMLInstanceSettings, ModuleHTML",
"IsActive": false,
"ShowAuthor": false,
"ShowDate": false,
"ShowCommentsCount": false,
"ShowLast2Comments": false,
"CMSModuleInstanceId": 545,
"ContainerClass": "default",
"ModuleType": "ModuleHTML",
"DisplayType": "Summary"
}
],
"Id": 0,
"Name": null,
"CreatedOn": "0001-01-01T00:00:00.0000000",
"CreatedBy": 0,
"LastModifiedOn": "0001-01-01T00:00:00.0000000",
"LastModifiedBy": 0
},
...
],
...
},
...
],
...
}
and I want to retrieve the page document and include the rows, columns and then only the CMSModuleInstanceSettings that are active.
I have tried:
var page = documentSession.Query<CMSPage>()
.SingleOrDefault(p => p.Id == pageId)
.Rows
.Any(x => x.Columns
.Any(z => z.CMSModuleInstanceSettings
.Where(m => m.IsActive == true)));
but it returns :
Error 1 Cannot convert lambda expression to delegate type
'System.Func<CMS.Models.CMSColumn,bool>' because some of
the return types in the block are not implicitly convertible
to the delegate return type
What am I doing wrong?
You are aware that you are actually doing a query then an in memory filter, right?
Split it like this:
var page = documentSession.Query<CMSPage>()
.SingleOrDefault(p => p.Id == pageId);
And:
var rows = page.Rows
.Any(x => x.Columns
.Any(z => z.CMSModuleInstanceSettings
.Where(m => m.IsActive == true)));
Where do you get the error now?
I'm sure there is a better way, but this is what I ended up doing....
var page = documentSession.Load<CMSPage>(pageId);
foreach (var row in page.Rows)
{
foreach (var column in row.Columns)
{
var settings = column.CMSModuleInstanceSettings.ToList();
settings.ForEach(x => settings.Remove(x));
column.CMSModuleInstanceSettings = settings;
}
}

Resources