Level 122
How is anyone (including yourself) supposed to understand that mess?
I'm using Laravel 5.4 and Yajra dataTable, everything working well if I'm retrieve the data normally. However, Once I start to use addRow and editRow, my page become very fast, I dont know why.
This is my controller:
return Datatables::of($allClients)
->addColumn('lead', function ($allClient) {
return '<a href="leads/' . $allClient->id . '" title="Move to this lead">' . $allClient->name . '(' .
$allClient->lead_number . ') </a>';
})
->addColumn('show', function ($allClient) {
return '<a onclick="show_leads()" class=" btn-icon aicon" style="cursor: pointer" title="Show">
<i class="material-icons ">remove_red_eye</i></a>';
})
->editColumn('status', function ($allClient) use ($all_status) {
if ($allClient->lead_stage == "Under_followup") {
$options = '';
foreach ($all_status as $statuss) {
if ($allClient->lead_status == $statuss->name) {
$options = $options . '<option value = "' . $statuss->name . '" disabled selected >' .
$statuss->name . '</option >';
} else {
$options = $options . '<option value = "' . $statuss->name . '" >' . $statuss->name . '</option>';
}
}
return '<select name="select_status" id="select_status" class="form-control activity_status"
onchange="select_change(' . $allClient->id . ', this)" >' . $options . ' </select>';
} else {
}
})
->editColumn('sms', function ($allClient) use ($all_sms) {
$smsoptions = '<option>Send Follow up...</option>';
foreach ($all_sms as $sms) {
$smsoptions = $smsoptions . '<option value = "' . $sms->content . '" >' . $sms->content . '</option>';
}
return '<select name="select_status" id="select_status" class="form-control activity_status"
onchange="select_sms(' . $allClient->id . ', this)" >' . $smsoptions . ' </select>';
})
->editColumn('assign', function ($allClient) use ($user_status, $all_users) {
if ($user_status == 'Admin') {
$options = '<option hidden="true">Select Stuff...</option>';
foreach ($all_users as $users) {
if ($allClient->user_id == $users->id) {
$options = $options . '<option value = "' . $users->id . '" disabled selected >' .
$users->name
. '</option >';
} else {
$options = $options . '<option value = "' . $users->id . '" >' . $users->name . '</option>';
}
}
return '<select name="user_id" class="form-control activity_status"
onchange="assign_users(' . $allClient->id . ', this)" >' . $options . ' </select>';
} else {
$query = User::find($allClient->user_id);
return $query->name;
}
})
->rawColumns(['lead', 'status', 'sms', 'assign'])
->make(true);
and once I'm using the addRow and editRow, Pagination also not working, and the data spent long time to show all. Any help please
Please or to participate in this conversation.