Kendo UI Grid, Group Header not collapsed when using row template - kendo-ui

I'm using Kendo UI grid, which has a Group by default. In the group header, it shows some aggregate info. It also uses row template to show row info, i.e. show a Check mark for 'True', Cross mark for 'False'. The code is at below:
<script id="rowTemplate" type="text/x-kendo-tmpl">
<tr>
<td>
</td>
<td>
#: Portfolio #
</td>
<td>
#: Folder #
</td>
<td>
#: FileName #
</td>
<td>
#: DocumentType #
</td>
<td>
#: ActionTime #
</td>
<td>
#: UserName #
</td>
<td>
#: CompanyName #
</td>
<td>
<img src="Images/downloaded_#:data.Downloaded#.png" alt="downloaded_#:data.Downloaded#.png" />
</td>
</tr>
</script>
var dataSource = new kendo.data.DataSource( {
schema: {
model: {
fields: {
... (some other fields)
DocumentType: { type: "string" },
CompanyName: { type: "string" },
Downloaded: { type: "number" }
}
}
},
pageSize: 200,
group: {
field: "CompanyName", aggregates: [
{ field: "CompanyName", aggregate: "count" },
{ field: "DocumentType", aggregate: "count" },
]
},
aggregate: [{ field: "CompanyName", aggregate: "count" },
{ field: "DocumentType", aggregate: "count" },
{ field: "Downloaded", aggregate: "sum" },
]
});
... (some other configurations)
dataSource: dataSource,
columns: [
... (some other fields)
{
field: "DocumentType", title: "Document Type", width: "80px"
},
{
field: "CompanyName", title: "Company Name", width: "100px"
, aggregates: ["count"]
, groupHeaderTemplate: "Company Name: #=value# (#=getDownloaded(data)# / #=count#)"
},
{
field: "Downloaded", title: "Downloaded", width: "50px"
},
],
sortable: true,
filterable: true,
selectable: true,
pageable: {
refresh: false,
pageSizes: [10, 20, 50, 100, 200], // true,
buttonCount: 5
},
scrollable: false,
rowTemplate: $.proxy(kendo.template($("#rowTemplate").html()), dataSource),
});
It works fine and show the grid correctly. However, if I click to collapse the group header (Yellow circle in below screen shot), it does not work. But if I do not use row template, i.e. comment out this line:
rowTemplate: $.proxy(kendo.template($("#rowTemplate").html()), dataSource),
Then it works fine (but I want to show the image for Downloaded column).
Is this a bug in Kendo? Anyone knows what I did wrong? Thanks.

This does not answer the question of whether this is a bug but you can see if this makes your grid work. Where you are having an issue with the row header not collapsing. Is wonder if there a hidden exception. As a workaround, you can add the image to the column using a column template the same way you are adding your Row Template. Also have you tried without using $.proxy?
...
{
field: "Downloaded", title: "Downloaded", width: "50px" ,
template: kendo.template($("#tmpColumnDownload").html())
}
..
<script id="tmpColumnDownload" type="text/x-kendo-template">
<img src="Images/downloaded_#=Downloaded#.png" alt="downloaded_#=Downloaded#.png" />
</script>

Related

Kendo Dropdown closes when we click to open it in IE browser

I am using Kendo UI v2018.1.221 in my page, whenever I click the dropdown to open it just opens and showing options and closes suddently before I make a selection. It uses serverfiltering as well.
I googled this a lot, but not finding any solutions for this.
sample code:
<table>
<TR>
<TD ALIGN="left" >Company:</TD>
<TD ALIGN="left" >
<select class="form-control" style="width: 80%" name="teamID" id="company">
</select>
</TD>
</TR>
<script>
var dropdown = $("#company").kendoDropDownList({
dataTextField: "name",
dataValueField: "id",
filter: 'contains',
optionLabel: 'Select a Company',
enable: true,
scrollable: {
virtual: true
},
virtual: {
itemHeight: 26
},
dataSource: {
type: "odata",
transport: {
read: {
dataType: "json",
url: "#url#"
}
},
batch: true,
pageSize: 80,
serverPaging: true,
serverFiltering: true,
schema: {
data: "data",
total: 'recordsTotal',
model: {
id: 'teamid',
fields: {
id: {
type: 'number'
},
name: {
type: 'string'
}
}
}
}
}
}).data("kendoDropDownList");
</script>
You need to take the focus away from the modal. You could do this on the open event.
open: function(e) {
$(document).off('focusin.bs.modal');
}
This seems to be a problem with the filter. Removing the filter fixed the problem for me.
var dropdown = $("#company").kendoDropDownList({
dataTextField: "name",
dataValueField: "id",
// filter: 'contains',
optionLabel: 'Select a Company',
enable: true,
...

how do i always show kendo grid default data row at the end of data source angularjs

how do i always show a default data entering row at the end of data source in kendo grid ??
i want to have a kendo grid with input row at the grid bottom at all times. when i enter data and press 'enter' key, the data should be inserted in the grid from top to bottom but the default data entry row should stay at grid bottom.
Below is the grid initialization. i have used angularjs / javascript with kendo grid.
//-> Grid Sample data for demo purposes
var s1 = [];
//##########################
//-> Grid Start
var configAddPaymentsEnter = {};
configAddPaymentsEnter.resizable = true
configAddPaymentsEnter.sortable = true;
configAddPaymentsEnter.pageable = false;
//{
// input: true,
// numeric: false
// };
configAddPaymentsEnter.editable =
{
createAt: 'bottom'
};
configAddPaymentsEnter.columns = [
{
field: "ConnectionReference",
attributes: {
"navi-text": ""
},
headerTemplate: 'Connection Reference',
template: '<input ng-keydown="AA(this,$event)" type ="text" ng-model="dataItem.ConnectionReference" class="k-fill text-right aa" format-number ng-pattern="/^[0-9]+(\.[0-9]{2})?$/" />',
width: "130px"
// ,aggregates: ["count"], footerTemplate: "Total Count: #=count#"
},
{
field: "ContractNumber",
attributes: {
"navi-text": ""
},
headerTemplate: 'Contract Number',
template: '<input ng-keydown="AA(this,$event)" type ="text" class="k-fill text-right aa" ng-model="dataItem.ContractNumber" format-number ng-pattern="/^[0-9]+(\.[0-9]{2})?$/" />',
width: "130px"
},
{
field: "Amount",
attributes: {
"navi-text": ""
},
headerTemplate: 'Amount',
template: '<input ng-keydown="AA(this,$event)" kendo-numeric-text-box type ="text" class="k-fill text-right aa" ng-model="dataItem.Amount" format-number ng-pattern="/^[0-9]+(\.[0-9]{2})?$/" />',
width: "130px"
// ,aggregates: ["sum"], footerTemplate: "Total Amount: #=sum#"
},
{
field: "ReferenceNumber",
attributes: {
"navi-text": ""
},
headerTemplate: 'Reference Number',
template: '<input ng-keydown="AA(this,$event)" type ="text" class="k-fill text-right aa" ng-model="dataItem.ReferenceNumber" format-number ng-pattern="/^[0-9]+(\.[0-9]{2})?$/" />',
width: "130px"
}
//,
//{
// field: "RowIndex",
// attributes: {
// "navi-text": ""
// },
// headerTemplate: 'RowIndex',
// template: '<input ng-keydown="AA(this,$event)" type ="text" class="k-fill text-right aa" ng-model="dataItem.RowIndex" format-number ng-pattern="/^[0-9]+(\.[0-9]{2})?$/" />',
// width: "130px"
//}
];
configAddPaymentsEnter.scrollable = true;
configAddPaymentsEnter.dataSource = new kendo.data.DataSource({
data: [s1],
//group: {
// field: "ConnectionReference", aggregates: [
// { field: "ConnectionReference", aggregate: "count" },
// { field: "Amount", aggregate: "sum" }
// ]
//},
//aggregate: [{ field: "ConnectionReference", aggregate: "count" },
// { field: "Amount", aggregate: "sum" }],
schema: {
model: {
id: "ID",
fields: {
'ConnectionReference': { editable: true, type: "number" },
'ContractNumber': { editable: true, type: "number" },
'Amount': { editable: true, type: "number" },
'ReferenceNumber': { editable: true, type: "number" }
//,
// 'RowIndex': { editable: false, type: "number" }
}
}
},
pageSize: 5000,
});
$scope.dgGridAddPaymentsEnter = new DataGrid();
$scope.dgGridAddPaymentsEnter.options(configAddPaymentsEnter);
$scope.Init = function (arg) {
$scope.dgGridAddPaymentsEnter.Init(arg);
};
$scope.Init = function (arg) {
$scope.dgGridAddPaymentsEnter.Init(arg);
};
This 'how to' example would be helpful:
http://docs.telerik.com/kendo-ui/controls/data-management/grid/how-to/Editing/add-row-when-tabbed-out-of-last-row
You can try using the Locking option of Kendo Grid UI.
http://docs.telerik.com/kendo-ui/controls/data-management/grid/appearance#locking
But, unfortunately frozen rows are not supported at the moment as far as i know. The best technique would be to include the frozen data in the Grid's footer, and take care of manually syncing any changes (edits) to the data values

Kendo Grid Filterable cell

I have a requirement in which I have to show two dropdown list in the Filterable cell of kendo grid. These two dropdown lists would filter two different columns in the kendo grid.
One thought I had is having template which would be some kendo container like some panel probably, and then add two dropdowns to that container.
Is this even possible? If yes how to achieve this?
Here is my kendo grid definition.
ctrl.mainGridOptions = {
dataSource: ctrl.gridDataSource,
columns: [
{
title: 'Col1-Col2',
field: 'Col1',
width: 200,
template: kendo.template($("#col1").html()),
filterable: { cell: { template: ctrl.coonetemplate, showOperators: false } }
},
{
field: 'Col3',
width: 150,
title: 'Col3',
template: kendo.template($("#col3").html()),
filterable: { cell: { template: ctrl.colthreeTemplate, showOperators: false } }
}
]
}
Here is a mockup of what I want to achieve.
There are a few different parts to this.
First, if you want to have multiple filter controls for different pieces of data, you should define a column for each one. Then, put a template on the first column to have it display the data for two columns. Use the attributes option to set a colspan=2. Then, use the attributes option on the second columns to set style="display:none".
The second part is getting the dropdowns. I generally prefer to use the values option to accomplish this. The code below uses this for the OrderID column. The other alternative was the approach you were on, which is to use the cell template. The code below uses this on the ShipName column.
<div id="example">
<div id="grid"></div>
<script>
$(document).ready(function() {
$("#grid").kendoGrid({
dataSource: {
type: "odata",
transport: {
read: "http://demos.telerik.com/kendo-ui/service/Northwind.svc/Orders"
},
schema: {
model: {
fields: {
OrderID: { type: "string" },
Freight: { type: "number" },
ShipName: { type: "string" },
OrderDate: { type: "date" },
ShipCity: { type: "string" }
}
}
},
pageSize: 20,
serverPaging: true,
serverFiltering: true,
},
height: 550,
filterable: {
mode: "row"
},
pageable: true,
columns: [
{
field: "OrderID",
width: 150,
attributes: {
colspan: 2
},
values: [
{text: "10248", value: "one"},
{text:"10249", value: "two"}
],
template: '#:OrderID# (#:ShipName#)',
filterable: {
cell: {
operator: "eq",
showOperators: false
}
}
},
{
attributes: {
style: "display:none"
},
field: "ShipName",
width: 200,
title: "Ship Name",
filterable: {
cell: {
template: function(args) {
args.element.kendoDropDownList({
dataSource: args.dataSource,
dataTextField: "ShipName",
dataValueField: "ShipName",
valuePrimitive: true
});
},
operator: "eq",
showOperators: false
}
}
},
{
field: "Freight",
width: 255,
filterable: false
}]
});
});
</script>
</div>
Runnable Demo
Kendo Grid filterable cell with custom options column wise and by using this solution it also overwrites general filters settings in case specific column requirement. ASP.NET MVC C#.
columns.Bound(c => c.columnName)
.Format("{0}%")
.Filterable(ftb => ftb
.Cell(cell => cell.ShowOperators(true))
.Extra(false)
.Operators(op => op
.ForNumber(fn => fn
.Clear()
.IsEqualTo(CommonResource.GridFilter_IsEqualTo)
)
)
)
.Title("Column Name");

KendoUI Grid Enum row filtering fails

I am one day old into Kendo, so I believe, I'm missing the obvious.
The grid seems to get stuck when tried to filter with Enum values set. Test Link
<div id="grid"></div>
<script>
$("#grid").kendoGrid({
columns: [
{
field: "category",
values: [{text: "Beverages", value: 1 }, {text: "Food", value: 2 }],
filterable: { mode: "row", cell: { showOperators: false, operator: "eq" } }
}
],
dataSource: [{ category: 1 }, { category: 2 } ],
filterable: {mode: "row"}
});
</script>
worked it out finally, missing type was all it seems needed. Demo Link
<div id="grid"></div>
<script>
$("#grid").kendoGrid({
columns: [
{
field: "category", type: "number",
values: [{text: "Beverages", value: 1 }, {text: "Food", value: 2 }],
filterable: { mode: "row", cell: { showOperators: false, operator: "eq" } }
}
],
dataSource: [{ category: 1 }, { category: 2 } ],
filterable: {mode: "row"}
});
</script>

Showing page sizes drop down list and refresh button on kendo grid MVVM

Does anyone know how to showing page sizes drop down list and refresh button on the footer kendo grid MVVM likes this
Here is my view code:
<div id="customer-grid"
data-role="grid"
data-sortable="true"
data-selectable="true"
data-pageable="true"
data-pagesizes="[5, 10, 20]"
data-columns='[
{ field: "CustomerID", title: "ID", width: "75px" },
{ field: "CompanyName", title: "Company"},
{ field: "ContactName", title: "Contact" },
{ field: "ContactTitle", title: "Title" },
{ field: "Address" },
{ field: "City" },
{ field: "Region" },
{ field: "PostalCode" },
{ field: "Country" },
{ field: "Phone" },
{ field: "Fax" } ]'
data-bind="source: customerSource">
</div>
and here is my data source code:
var customerSource = new kendo.data.DataSource({
transport: {
read: {
async: false,
url: crudServiceBaseUrl,
dataType: "json"
}
},
serverPaging: true,
pageSize: 10,
schema: {
model: customerModel,
data: "data",
total: "count"
},
});
Thanks in advance.
You should define data-pageable as:
data-pageable="{ refresh: true, pageSizes: [5, 10, 20] }"
Please, note that the array of page sizes is defined in data-pageable and not in data-pagesizes.
So your grid definition would be:
<div id="customer-grid"
data-role="grid"
data-sortable="true"
data-selectable="true"
data-pageable="{ refresh: true, pageSizes: [5, 10, 20] }"
data-columns='[
{ field: "CustomerID", title: "ID", width: "75px" },
{ field: "CompanyName", title: "Company"},
{ field: "ContactName", title: "Contact" },
{ field: "ContactTitle", title: "Title" },
{ field: "Address" },
{ field: "City" },
{ field: "Region" },
{ field: "PostalCode" },
{ field: "Country" },
{ field: "Phone" },
{ field: "Fax" } ]'
data-bind="source: customerSource">
</div>
Check it here : http://jsfiddle.net/9zL6J/

Resources