我尝试将导出按钮添加到我的数据表中,我的表中包含选择框,问题是 - 它导出选择框中包含的所有选项值...我使用ajax从服务器获取结果然后操纵不同的数据在使用如下dataSrc
函数渲染之前:
dataTableInit: function (columns_def) {
var me = this;
me.dataTable_obj = $('#leads_table').DataTable({
"pageLength": per_page,
dom: 'Blfrtip',
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
],
"order": [order],
"ajax": {
url: route,
type: method,
data: filtering_data,
"dataSrc": function (json) {
return me.setLeadsTableData(json);
}
},
"columns": columns_def,
....
Run Code Online (Sandbox Code Playgroud)
在setLeadsTableData
我检查从服务器返回的列然后如果它是一个应该是一个选择框的列我正在改变它模板,如下所示:
setStatusesSelectBox: function (status_obj, lead_id) {
var me = this;
var statuses_list = '';
var bg_color = status_obj.name == "new" ? me.new_status_row_bg_color : '';
$.each(me.client_statuses, function (key, val) { …
Run Code Online (Sandbox Code Playgroud) 我基于Laravel创建一个项目,并具有以下表:companies
,attributes
和attribute_company
用作attribute_company
连接表companies
和attributes
数据透视表时的多对多关系。
我attribute_id
从客户那里得到了一个数组,我需要获得完全具有整个属性的公司的结果。
我发现的唯一解决方案是将查询whereHas
与whereIn
内部结合在一起,如下所示:
Company::whereHas('attributes', function (Builder $query) use ($atts_ids) {
$query->whereIn('attribute_id', $atts_ids);
})->get();
Run Code Online (Sandbox Code Playgroud)
companies
如果attribute_id
找到至少一个(不是我要查找的),则此查询将返回。
如果有人可以让我更清楚一点,那就太好了。
谢谢大家 :)
嘿,我看到很多关于这个话题的问题,但没有一个适合我的问题.我正在尝试使用localStorage存储用户自定义首选项,我尝试将一个json对象放入localStorage键并稍后使用它.开头的对象看起来像这样:
Object {test: "{a:"b",c:"d"}"}
Run Code Online (Sandbox Code Playgroud)
该JSON.parse
方法返回一个错误,我所做的是:
var local_storage = getAll();
$.parseJSON(JSON.stringify(local_storage.test.substring(0,0).substring(0,local_storage.length,-1)));
Run Code Online (Sandbox Code Playgroud)
输出是:
{a:"b",c:"d"}
Run Code Online (Sandbox Code Playgroud)
但我不能将它用作local_storage.test.a为什么会这样,解决方案是什么?
thx的帮助:)
编辑!
感谢@Oli Soproni B,解决方案是:
var key = {a:"b",c:"d"};
var l = JSON.stringify(key);
localStorage.setItem('test',l);
var local_storage = $.parseJSON(localStorage.getItem('test'));
console.log(local_storage);
console.log(local_storage.a);
Run Code Online (Sandbox Code Playgroud) 我在角度和laravel中构建一个API服务,当我向API发出GET调用时,Everythings工作正常,但是当我触发POST调用时,服务仍然使用GET方法而不是POST.那是我的服务:
function LeadsAPI($http,$q,BASE_URL)
{
this.updateLead = function (lead_data) {
var url = BASE_URL+"/leads/update/";
var deferred = $q.defer();
$http.post(url , lead_data).then(function(response){
deferred.resolve(response.data);
});
return deferred.promise;
}
}
Run Code Online (Sandbox Code Playgroud)
我从控制器调用此函数:
LeadsController.$inject = ['$scope', 'LeadsAPI'];
function LeadsController($scope , LeadsAPI)
{
LeadsAPI.updateLead({'lead_id' : res._id, 'the_lead': {'fist_name' : 'asd asd'}}).then(function (res) {
console.log(res);
});
}
Run Code Online (Sandbox Code Playgroud)
我尝试将参数作为字符串传递("a = b&c = d ...")并添加标题:
$http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
Run Code Online (Sandbox Code Playgroud)
在run
我的应用程序模块实例化的功能,但是,我不断收到405 (Method Not Allowed)
错误.任何想法为什么以及如何解决它?非常感谢你们!:)
我正在开发一个使用Laravel 5.1作为服务器端框架的项目,我使用jQuery Datatables插件和用于Laravel的yajrabox Datatables插件构建了一个表来显示潜在客户.
我正在实现服务器端处理,但是我需要在将数据发送到客户端之前对其进行操作,为此,我需要首先提取我想要显示的所有数据(操作它),这使得该过程非常长.这是我正在使用的代码:
public function index()
{
return view('leads.test')->with($data);
}
Run Code Online (Sandbox Code Playgroud)
返回视图,并:
public function getLeads()
{
$end = new \MongoDate(Carbon::now()->endOfDay()->setTimezone(Client::getTimezone(5))->timestamp);
$start = new \MongoDate(Carbon::now()->subWeek()->startOfDay()->setTimezone(Client::getTimezone(5))->timestamp);
return \Datatables::of(collect($this->setLeadData(Lead::where('deleted',0)->where('client_id','5')->whereBetween('created_at',[$start,$end])->orderBy('created_at','desc')->get())))->make(true);
}
Run Code Online (Sandbox Code Playgroud)
返回引导,最后一个,操作过程:
private function setLeadData($leads)
{
$rtn = [];
$row = [];
foreach ($leads as $lead) {
$row['DT_RowId'] = $lead->_id;
if(\Auth::user()->canDeleteLeads()){
$row['checkbox'] = "<input type='checkbox' class='bulk-delete-leads-checkbox' name='bulk_delete_leads[]' id='".$lead->_id."' /><label for='".$lead->_id."'></label>";
}
if(Carbon::createFromFormat("Y-m-d H:i:s", $lead->created_at)->isSameDay(Carbon::now()->startOfDay())){
$row['date'] = "<i class='fa fa-clock-o'></i> at ".Carbon::createFromFormat("Y-m-d H:i:s", $lead->created_at)->timezone(Client::getTimezone())->format("H:i");
}else{
$row['date'] = "<i class='fa fa-clock-o'></i> ".Carbon::createFromFormat("Y-m-d H:i:s", $lead->created_at)->timezone(Client::getTimezone())->toDateTimeString();
} …
Run Code Online (Sandbox Code Playgroud) datatables ×2
javascript ×2
php ×2
angularjs ×1
api ×1
eloquent ×1
export ×1
http ×1
jquery ×1
json ×1
laravel ×1
laravel-5.1 ×1
tabletools ×1