zupit.directive('kendoResize', [
function() {
return {
restrict: 'A',
link:function($scope, el, attrs) {
$(window).on("resize", function () {
kendo.resize(el);
});
}
}
}
]);
zupit.service('Zupit.Core.KendoHelper', ['$translate', 'config', function ($translate, config) {
return {
flatColumn: function(field, title, width) {
title = $translate.instant(title);
var ret = {
field: field,
title: title,
filterable: false,
sortable: false,
headerTemplate: title,
menu: false,
headerAttributes: {
"class": 'hide-header'
}
};
if (width !== undefined) {
ret.attributes = {
style: 'width:' + width
};
}
return ret;
},
gridOptions: function (columns, pageable, sortable, filterable,columnMenu,dataBound) {
pageable = pageable === undefined ? true : pageable;
filterable = filterable === undefined ? true : filterable;
sortable = sortable === undefined ? true : sortable;
columnMenu = columnMenu || false;
columns = columns || false;
return {
sortable: sortable,
scrollable:true,
noRecords: {
template: "
{{'EMPTY_ROW_TEMPLATE'|translate}}
"
},
pageable:pageable? {
pageSizes:config.clientOptions.pageSizes
}:false,
filterable:filterable? {
mode: 'row'
}:false,
columnMenu:{
columns: columnMenu,
filterable:filterable,
sortable:sortable
},
columns: columns,
dataBound:function(e) {
if (dataBound !== undefined)
dataBound(e);
}
};
},
clientSideGridOptions: function (columns, pageable, sortable, filterable, columnMenu, dataBound) {
pageable = pageable === undefined ? true : pageable;
filterable = filterable === undefined ? true : filterable;
sortable = sortable === undefined ? true : sortable;
columnMenu = columnMenu || false;
columns = columns || false;
return {
sortable: sortable,
scrollable: true,
noRecords: {
template: "{{'EMPTY_ROW_TEMPLATE'|translate}}
"
},
pageable: pageable ? {
pageSizes: config.clientOptions.pageSizes
} : false,
filterable: filterable ? {
mode: 'row'
} : false,
columnMenu: {
columns: columnMenu,
filterable: filterable,
sortable: sortable
},
columns: columns,
dataBound: function (e) {
if (dataBound !== undefined)
dataBound(e);
}
};
},
dataSource: function (readFn,model, pageable, sortable, filterable) {
pageable = pageable === undefined ? true : pageable;
filterable = filterable === undefined ? true : filterable;
sortable = sortable === undefined ? true : sortable;
return {
transport: {
dataType: 'json',
read: readFn
},
schema: {
model:model,
data: 'data',
total: 'total',
errors: 'errorMessage'
},
serverSorting: sortable,
serverFiltering: filterable,
serverPaging: pageable,
pageSize: config.clientOptions.defaultPageSize
};
},
dateBoundColumn:function(field,title,filterable,sortable,format,width,align) {
align = align || 'left';
title = $translate.instant(title);
if (filterable === undefined) filterable = true;
if (sortable === undefined) sortable = true;
var ret = {
field: field,
title: title,
menu:false,
filterable: filterable ? {
cell: {
operator: "contains"
}
} :false,
sortable: sortable
};
if (format !== undefined)
ret.format = format;
if (width !== undefined) {
ret.attributes = {
style: 'text-align:'+align+';width:' + width
};
ret.headerAttributes = {
style: 'text-align:' + align + ';width:' + width
};
}
return ret;
},
templateDateBoundColumn: function (field,template, title, filterable, sortable, format, width, align) {
align = align || 'left';
title = $translate.instant(title);
if (filterable === undefined) filterable = true;
if (sortable === undefined) sortable = true;
var ret = {
field: field,
title: title,
menu: false,
template:template,
filterable: filterable,
sortable: sortable
};
if (format !== undefined)
ret.format = format;
if (width !== undefined) {
ret.attributes = {
style: 'text-align:' + align + ';width:' + width
};
ret.headerAttributes = {
style: 'text-align:' + align + ';width:' + width
};
}
return ret;
},
numericDateBoundColumn: function (field, title, filterable, sortable, format, width) {
title = $translate.instant(title);
if (filterable === undefined) filterable = true;
if (sortable === undefined) sortable = true;
var ret = {
field: field,
title: title,
menu: false,
filterable: filterable,
sortable: sortable
};
if (format !== undefined)
ret.format = format;
if (width !== undefined) {
ret.attributes = {
style: 'text-align:right;width:' + width
};
ret.headerAttributes = {
style: 'text-align:left;width:' + width
};
} else {
ret.attributes = {
style: 'text-align:right'
};
ret.headerAttributes = {
style: 'text-align:left'
};
}
return ret;
},
htmlDateBoundColumn: function (field, title, filterable, sortable, format, width, align) {
align = align || 'center';
title = $translate.instant(title);
if (filterable === undefined) filterable = true;
if (sortable === undefined) sortable = true;
var ret = {
field: field,
title: title,
menu: true,
filterable: filterable,
sortable: sortable,
encoded:false
};
if (filterable || sortable) {
ret.menu = true;
ret.columnMenu = {
columns: false,
filterable: filterable,
sortable: sortable
};
}
if (format !== undefined)
ret.format = format;
if (width !== undefined) {
ret.attributes = {
style: 'text-align:' + align + ';width:' + width
};
ret.headerAttributes = {
style: 'text-align:' + align + ';width:' + width
};
}
return ret;
},
buttonColumn:function(label, width, command, id, btnClass,template) {
label = $translate.instant(label);
var ret = {
menu: false,
field: id,
title: ' ',
columnMenu: {
columns: false,
filterable: false,
sortable: false
},
template: '',
sortable: false,
filterable: false
};
if (width === undefined) width = 150;
if (width !== undefined) {
ret.attributes = {
"class": "btntd",
style: 'text-align:center;width:' + width+'px'
};
ret.headerAttributes = {
"class": "btntd",
style: 'text-align:center;width:' + width + 'px;font-size:0'
};
}
return ret;
},
twoButtonColumn: function (label,label2, width, command,command2, id, btnClass,btnClass2, template) {
label = $translate.instant(label);
label2 = $translate.instant(label2);
var ret = {
menu: false,
field: id,
title: ' ',
columnMenu: {
columns: false,
filterable: false,
sortable: false
},
template: '',
sortable: false,
filterable: false
};
if (width === undefined) width = 150;
if (width !== undefined) {
ret.attributes = {
"class": "btntd",
style: 'text-align:center;width:' + width + 'px'
};
ret.headerAttributes = {
"class": "btntd",
style: 'text-align:center;width:' + width + 'px;font-size:0'
};
}
return ret;
},
customButtonColumn: function (id,template,width) {
var ret = {
menu: false,
field: id,
title: ' ',
columnMenu: {
columns: false,
filterable: false,
sortable: false
},
template: template,
sortable: false,
filterable: false
};
if (width === undefined) width = 150;
ret.attributes = {
"class": "btntd",
style: 'text-align:center;width:' + width + 'px'
};
ret.headerAttributes = {
"class": "btntd",
style: 'text-align:center;width:' + width + 'px;font-size:0'
};
return ret;
},
customDataColumn: function (id, title, template, filterable, sortable, width,column,customClass) {
title = $translate.instant(title);
if (filterable === undefined) filterable = true;
if (sortable === undefined) sortable = true;
if (width === undefined) width = 'auto';
if (column === undefined) column = true;
if (customClass === undefined) customClass = "";
if (!filterable && !sortable) column = false;
var ret = {
menu: false,
field: id,
title: title,
columnMenu:column? {
columns: false,
filterable: filterable,
sortable: sortable
}:false,
template: template,
sortable: sortable,
filterable: filterable
};
if (width === undefined) width = 150;
ret.attributes = {
style: 'width:' + width
};
ret.headerAttributes = {
"class": customClass,
style: 'width:' + width
};
return ret;
}
};
}
]);