I am creating a grid using AngularJS. The data is added correctly, but I can not configure the size of the columns. I'm setting the width in the code, but it does not seem to work.
Code:
<div kendo-grid
k-data-source="frigobarGridOptions"
k-selectable="'row'"
k-pageable='{ "pageSize": 5, "pageSizes": true }'
k-columns='[
{ "field": "ItemId", "title": "Id", width: "130px"},
{ "field": "Descricao", "title": "Descrição", width: "250px"},
{ "field": "Quantidade", "title": "Quantidade", width: "100px" }
]'>
</div>
Follow the screenshot of the grid.
Currently i'm running into an issue with the visibility of one column in my Kendo Grid while using AngularJS in combination with odata-v4.
When the grid initially loads all data is shown for each column, but after either an add or update action, the column showing the type doesn't display the value anymore, spefically for that record.
We resolve the odata type to a more readable version with a scope variable that contains the possible types
1.
$scope.types = [
2.
{ value:
"#Awvn.Model.Discounts.CatalogDiscountRule"
, text:
"Catalog"
},
3.
{ value:
"#Awvn.Model.Discounts.ProgramFormDiscountRule"
, text:
"Program Form"
},
4.
{ value:
"#Awvn.Model.Discounts.ProductDiscountRule"
, text:
"Product"
},
5.
];
Our Model and options definion for the grid, they both get send to a function that combines and sets required default settings for our data grid:
001.
$q.all([
002.
DropDownListService.resolveDropDownList(
"Employers"
),
003.
DropDownListService.resolveEnum(
"Awvn.Model.Discounts.DiscountCalculationMethod"
),
004.
DropDownListService.resolveDropDownList(
"Catalogs"
),
005.
DropDownListService.resolveComboBox(
"CostTypes"
),
006.
DropDownListService.resolveComboBox(
"Products?$select=Id,Title,CatalogId"
),
007.
]).then(
function
(data) {
008.
var
model = {
009.
id:
"Id"
,
010.
fields: {
011.
Id: { type:
"number"
},
012.
EmployerId: { type:
"number"
, defaultValue: Number($routeParams.employerId) ? Number($routeParams.employerId) :
null
, validation: { required:
false
} },
013.
EffectiveFromDate: { type:
"indicia.date"
, defaultValue:
new
Date(
new
Date().setDate(
new
Date().getDate() + 1)) },
014.
DiscountAmount: { type:
"indicia.percentage"
, defaultValue: 0 },
015.
ResellerFeeAmount: { type:
"indicia.percentage"
, defaultValue: 0 },
016.
CalculationMethod: { type:
"string"
, validation: { required:
true
} },
017.
Tag: { type:
"string"
, nullable:
true
},
018.
ExcludedCostTypes: { type:
"indicia.multiselect"
, entityType:
"CostTypes"
},
019.
020.
CatalogId: {
021.
type:
"indicia.foreignkey.nullable"
, validation: {
022.
required:
function
(input) {
023.
if
(input.is(
"[name='CatalogId']"
) && input.val() ===
""
&& $(
"select[name='Type']"
).val() ===
"#Awvn.Model.Discounts.CatalogDiscountRule"
) {
024.
input.attr(
"data-required-msg"
,
"This field is required for a Catalog Discount Rule."
);
025.
return
false
;
026.
}
027.
028.
return
true
;
029.
}
030.
}
031.
},
032.
033.
ProgramFormId: {
034.
type:
"number"
, validation: {
035.
required:
function
(input) {
036.
if
(input.is(
"[name='ProgramFormId']"
) && input.val() ===
""
&& $(
"select[name='Type']"
).val() ===
"#Awvn.Model.Discounts.ProgramFormDiscountRule"
) {
037.
input.attr(
"data-required-msg"
,
"This field is required for a Program Form Discount Rule."
);
038.
return
false
;
039.
}
040.
041.
return
true
;
042.
}
043.
}
044.
},
045.
046.
ProductId: {
047.
type:
"indicia.foreignkey.nullable"
, validation: {
048.
required:
function
(input) {
049.
if
(input.is(
"[name='ProductId']"
) && input.val() ===
""
&& $(
"select[name='Type']"
).val() ===
"#Awvn.Model.Discounts.ProductDiscountRule"
) {
050.
input.attr(
"data-required-msg"
,
"This field is required for a Product Discount Rule."
);
051.
return
false
;
052.
}
053.
054.
return
true
;
055.
}
056.
}
057.
},
058.
059.
Type: { type:
"string"
, from:
"['@odata.type']"
, validation: { required:
true
} },
060.
}
061.
};
062.
063.
var
options = {
064.
expand: [
"ExcludedCostTypes"
],
065.
dataSource: {
066.
filter: [],
067.
sort: [{ field:
"EffectiveFromDate"
, dir:
"desc"
}],
068.
sendFields: {
069.
admin:
function
(dataItem) {
070.
if
(dataItem[
"@odata.type"
] ===
"#Awvn.Model.Discounts.CatalogDiscountRule"
) {
071.
return
{
072.
create: [
"@odata.type"
,
"EmployerId"
,
"EffectiveFromDate"
,
"DiscountAmount"
,
"ResellerFeeAmount"
,
"CalculationMethod"
,
"Tag"
,
"CatalogId"
],
073.
update: [
"Id"
,
"@odata.type"
,
"EmployerId"
,
"EffectiveFromDate"
,
"DiscountAmount"
,
"ResellerFeeAmount"
,
"CalculationMethod"
,
"Tag"
,
"CatalogId"
]
074.
};
075.
}
else
if
(dataItem[
"@odata.type"
] ===
"#Awvn.Model.Discounts.ProgramFormDiscountRule"
) {
076.
return
{
077.
create: [
"@odata.type"
,
"EmployerId"
,
"EffectiveFromDate"
,
"DiscountAmount"
,
"ResellerFeeAmount"
,
"CalculationMethod"
,
"Tag"
,
"ProgramFormId"
],
078.
update: [
"Id"
,
"@odata.type"
,
"EmployerId"
,
"EffectiveFromDate"
,
"DiscountAmount"
,
"ResellerFeeAmount"
,
"CalculationMethod"
,
"Tag"
,
"ProgramFormId"
]
079.
};
080.
}
else
if
(dataItem[
"@odata.type"
] ===
"#Awvn.Model.Discounts.ProductDiscountRule"
) {
081.
return
{
082.
create: [
"@odata.type"
,
"EmployerId"
,
"EffectiveFromDate"
,
"DiscountAmount"
,
"ResellerFeeAmount"
,
"CalculationMethod"
,
"Tag"
,
"ProductId"
],
083.
update: [
"Id"
,
"@odata.type"
,
"EmployerId"
,
"EffectiveFromDate"
,
"DiscountAmount"
,
"ResellerFeeAmount"
,
"CalculationMethod"
,
"Tag"
,
"ProductId"
]
084.
};
085.
}
086.
}
087.
}
088.
},
089.
dataGrid: {
090.
toolbar: [
'create'
, {
091.
name:
"edit"
,
092.
title:
"Bulk Copy"
,
093.
template:
'<a title="Bulk copy discount rules for the current selection or (when no specific rows are selected) for all (!) rules matching the current filter." ng-click="bulkEdit()" class="k-button k-button-icontext k-grid-edit"><span class="k-icon k-i-copy"></span>Bulk Copy</a>'
094.
}, {
095.
name:
"delete"
,
096.
title:
"Bulk Delete"
,
097.
template:
'<a title="Bulk delete discount rules for the current selection or (when no specific rows are selected) for all (!) rules matching the current filter." ng-click="bulkDelete()" class="k-button k-button-icontext k-grid-edit"><span class="k-icon k-i-delete"></span>Bulk Delete</a>'
098.
}],
099.
columns: [
100.
{ title:
""
, template:
'<input class="checkbox" type="checkbox" ng-click="onClickCheckbox(dataItem.Id)" />'
, width: 28 },
101.
{ field:
"Tag"
, title:
"Tag"
},
102.
{ field:
"EffectiveFromDate"
, title:
"Effective From"
, width:
"150px"
},
103.
{
104.
field:
"Type"
, title:
"Type"
, values: $scope.types, width: 180,
105.
dependencies: [
106.
{ condition:
function
(val) {
return
val ===
"#Awvn.Model.Discounts.CatalogDiscountRule"
}, fields: [
"CatalogId"
] },
107.
{ condition:
function
(val) {
return
val ===
"#Awvn.Model.Discounts.ProgramFormDiscountRule"
}, fields: [
"ProgramFormId"
] },
108.
{ condition:
function
(val) {
return
val ===
"#Awvn.Model.Discounts.ProductDiscountRule"
}, fields: [
"ProductId"
,
"CatalogId"
] }
109.
]
110.
},
111.
{ field:
"DiscountAmount"
, title:
"Discount"
, width: 180, },
112.
{ field:
"ResellerFeeAmount"
, title:
"Reseller Fee"
, width: 180 },
113.
{ field:
"CalculationMethod"
, title:
"CalculationMethod"
, values: data[1] },
114.
{ field:
"CatalogId"
, title:
"Catalog"
, values: data[2], hidden:
true
},
115.
{ field:
"ProductId"
, title:
"Product"
, hidden:
true
},
116.
{ field:
"ProgramFormId"
, title:
"Program Form"
, hidden:
true
},
117.
{ field:
"ExcludedCostTypes"
, title:
"Excluded Cost Types"
, values: data[3] },
118.
],
119.
editable: {
120.
mode:
"popup"
,
121.
template: kendo.template($(
"#discountRulesPopup"
).html())
122.
}
123.
}
124.
};
In our model we have to use "from: "['@odata.type']", to get the data to the Type field out of the odata-v4 attribute. We also have to use the formatting with the square brackets, if we don't use this the code won't work. I've also tried using a template for the values but I couldn't manage to get it to work that way either. With some research i also discovered that the return might be an issue with not giving all data but i also get the fully filled record returned from the server see below
01.
{
02.
"@odata.context"
:
"https://localhost/Awvn.Admin.Api/odata/$metadata#DiscountRules/Awvn.Model.Discounts.CatalogDiscountRule/$entity"
,
03.
"@odata.type"
:
"#Awvn.Model.Discounts.CatalogDiscountRule"
,
04.
"Id"
: 18,
05.
"Tag"
:
"fdfdsfds"
,
06.
"EmployerId"
: 1,
07.
"EffectiveFromDate"
:
"2018-02-06T13:33:54.108Z"
,
08.
"DiscountAmount"
: 0,
09.
"ResellerFeeAmount"
: 0.01,
10.
"CalculationMethod"
:
"DiscountFirst"
,
11.
"CatalogId"
: 1
12.
}
To summarize, the @odata.type value is being shown in the grid column on an initial load, but after the a crud action, the type for the effected row disappears.
I am dynamically hiding a command button on dataBound. When editing I edit that row then switch to another row to edit the hidden button is displayed.
How can I keep this hidden button?
<script>
$(document).ready(function () {
var crudServiceBaseUrl = "https://demos.telerik.com/kendo-ui/service",
dataSource = new kendo.data.DataSource({
transport: {
read: {
url: crudServiceBaseUrl + "/Products",
dataType: "jsonp"
},
update: {
url: crudServiceBaseUrl + "/Products/Update",
dataType: "jsonp"
},
destroy: {
url: crudServiceBaseUrl + "/Products/Destroy",
dataType: "jsonp"
},
create: {
url: crudServiceBaseUrl + "/Products/Create",
dataType: "jsonp"
},
parameterMap: function(options, operation) {
if (operation !== "read" && options.models) {
return {models: kendo.stringify(options.models)};
}
}
},
batch: true,
pageSize: 20,
schema: {
model: {
id: "ProductID",
fields: {
ProductID: { editable: false, nullable: true },
ProductName: { validation: { required: true } },
UnitPrice: { type: "number", validation: { required: true, min: 1} },
Discontinued: { type: "boolean" },
UnitsInStock: { type: "number", validation: { min: 0, required: true } }
}
}
}
});
gridCommands =[{
name: "edit",
text: " ",
mode: "inline"},
{
name:"destroy",
text: " "},
{
name: "exportproduct",
text:"Export",
click: ExportProduct}
];
$("#grid").kendoGrid({
dataSource: dataSource,
pageable: true,
height: 550,
toolbar: ["create"],
columns: [
"ProductName",
{ field: "UnitPrice", title: "Unit Price", format: "{0:c}", width: "120px" },
{ field: "UnitsInStock", title:"Units In Stock", width: "120px" },
{ field: "Discontinued", width: "120px", editor: customBoolEditor },
{ command: gridCommands, title: " ", width: "250px" }],
editable: "inline",
dataBound: function (e) {
var columns = e.sender.columns,
dataItems = e.sender.dataSource.view();
for (var i = 0; i < dataItems.length; i++) {
var product = dataItems[i].get("ProductName");
if (product === "Chang") {
var row = e.sender.tbody.find("[data-uid='" + dataItems[i].uid + "']");
var cell = row.children().eq(4);
var btn = cell.children().eq(2);
btn.hide();
}
}
}
});
});
function customBoolEditor(container, options) {
var guid = kendo.guid();
$('<input class="k-checkbox" id="' + guid + '" type="checkbox" name="Discontinued" data-type="boolean" data-bind="checked:Discontinued">').appendTo(container);
$('<label class="k-checkbox-label" for="' + guid + '"></label>').appendTo(container);
}
function ExportProduct(container) {
alert(container.name);
}
</script>
I have developed a workflow builder tool using RADDiagram and I am, for the most part, quite happy with the result. That said, I would like try to add a bit more polish to the finished product by adding "arrows" to the tooltip callout pointing to the selected shape (see attached image). Is this mod possible? FWIW, I have tooltips working now but they are simply rounded rectangles.
Thanks.
Hello,
installed couple of a11y extensions to Chrome, tested some of pages using Kendo widgets and got bunch of ARIA errors reported. Not sure what is the actual problem for all of them, but when read through specs, I found that e.g. aria-valuenow attribute should not be present if empty and furthermore should be used mainly for numeric values, see https://www.w3.org/TR/wai-aria-1.1/#aria-valuenow for details.
On the other hand, is it even necessary to have this attribute for form fields such as password, e-mail or plain textbox?
I am finding that the tooltip shown is not what is produced by the tooltip.template.
https://dojo.telerik.com/utAxum
I have added export to pdf button in my graph. On click, Following error occurs:
"TypeError: a[6] is undefined"
Kindly assist
Hello, I have a problem with my code.
In mi command i try to use a template whit a "If" statement, but doesn't work, what is wrong?
command:
{
text: "Work",
click: function (e) {
angular.copy(this.dataItem($(e.currentTarget).closest("tr")), vmOrd.DataRel);
$scope.$broadcast('loadData', vmOrd.DataRel);
$scope.$apply();
},
template: '#if(Quantity != 0){# <a href="\\#" class="k-button k-button-icontext k-grid-Work"><span class="fa fa-2x fa fa-pencil-square-o text-default"></span></a> # } else {# <a href="\\#" class="k-button k-button-icontext k-grid-Work"><span class="fa fa-2x fa fa-pencil text-default"></span></a> #} #',
},
<script id=
"AirPricingWithoutPNRViewModelItemTemplate"
type=
"text/x-kendo-template"
>
<div class=
"postpricingItem"
>
<div>
<table>
<tbody data-template=
"T2Template"
data-bind=
"source: data"
></tbody>
</table>
</div>
<div>Quote: <span
data-bind=
"text: Total"
></span></div> /* attr: title to be attached to this span */
</div>
</script>
<script id=
"T1Template"
type=
"text/x-kendo-template"
>
<tr>
<td>TST </td>
<td title=
"Passenger Type"
data-bind=
"text: UnitQualifier"
></td>
<td title=
"Passenger Quantity"
data-bind=
"text: Quantity"
></td>
<td title=
"PricingPCC"
data-bind=
"text: OptionFilters.PricingPccInformation.PCCCode"
></td>
#if (data.lkpStatus=="D") {#
<td title=
"Deleted TST"
><i class=
"fa text-danger fa-times"
aria-hidden=
"true"
></i></td>
#} else {#
#}#
<td title=
"Price"
data-bind=
"text: TotalSalesPriceToDisplay"
></td>
</tr>
</script>