Hello, I'm really new using Kendo. I'm trying to open a window from a custom column in kendo grid. What am I doing wrong? Because the window opens just the first time.
If someone can help me, I would be really grateful.
Thanks,
<div id=
"window"
></div>
<div id=
"grid"
></div>
<script language=
"javascript"
type=
"text/javascript"
>
$(document).ready(
function
() {
var
isShareholder =
"True"
; //comes from code-behind
if
(isShareholder ==
"True"
) {
var
serviceUrl =
'/mif/apps/Services/ControlServices.svc'
+
'/GetShareholdersByType'
;
var
serviceData =
'{ "appKey" : "E4AC543E-9D95-C360-EAF1EFC5A4CA716F", "operationNum" : "EQU/MS-11838-BO", "type" : "FUND_INVESTOR" }'
;
$.ajax({
url: serviceUrl,
data: serviceData,
type:
"POST"
,
processData:
true
,
contentType:
"application/json"
,
timeout: 10000,
success:
function
(response, status) {
if
(status ==
"success"
) {
BindGrid(response);
}
},
error:
function
(message) {
alert(message.responseText);
}
});
}
});
function
BindGrid(data) {
var
dataSource =
new
kendo.data.DataSource({
data: data,
schema: {
model: {
fields: {
Code: { type:
"string"
},
OperationNum: { type:
"string"
},
ShareholderId: { type:
"number"
},
ShareholderName: { type:
"string"
},
AcronymIdb: { type:
"string"
},
InvestmentAmount: { type:
"number"
},
InvestmentExchangeRate: { type:
"number"
},
InvestmentDate: { type:
"date"
},
InvestmentCurrencyId: { type:
"string"
},
CurrencyName: { type:
"string"
},
InvestmentUsEqu: { type:
"number"
},
SharePercentage: { type:
"number"
},
Keyword: { type:
"string"
}
}
}
},
aggregate: [
{ field:
"ShareholderName"
, aggregate:
"count"
},
{ field:
"InvestmentAmount"
, aggregate:
"sum"
},
{ field:
"SharePercentage"
, aggregate:
"sum"
}
]
//,pageSize: 3
});
$(
"#grid"
).kendoGrid({
dataSource: dataSource,
//change: onChange,
selectable:
"multiple"
,
//height: 400,
filterable:
true
,
sortable:
true
,
pageable:
false
,
scrollable:
false
,
resizable:
true
,
animation: {
open: { effects:
"fadeIn"
}
},
//dataBound: function (e) {
// alert('databound');
//},
columns: [
{
field:
"ShareholderName"
, title:
'Shareholder'
//, footerTemplate: '<div style="font-color: Red;">Totals' + ": #=count#" + "</div>"
}
, {
field:
"SharePercentage"
, title:
'SharePercentageAbbr'
, format:
"{0}%"
, width:
"15%"
, filterable:
false
, template:
'<div style="text-align:center;">#=SharePercentage#%</div>'
//, footerTemplate: '<div style="text-align:center;">#=sum#%</div>'
}
, {
field:
"InvestmentAmount"
, title:
'InvestmentAmountAbbr'
, format:
"{0:C}"
, width:
"15%"
, filterable:
false
, template:
"<div style='text-align:right;'>#=kendo.toString(InvestmentAmount, 'C')#</div>"
, footerTemplate:
"<div style='text-align:right; background-color: \\#8EBC00; color: \\#FFFFFF; font-weight: bold;'>#=kendo.toString(sum, 'C')#</div>"
}
, {
field:
"InvestmentDate"
, title:
'InvestementDateAbbr'
, format:
"{0:dd/MMM/yy}"
, filterable:
false
, template:
"<div style='text-align:center;'>#=kendo.toString(InvestmentDate, 'dd/MMM/yy')#</div>"
, width:
"10%"
}
, {
field:
"CurrencyName"
, title:
'InvestmentCurrencyAbbr'
, filterable:
false
, width:
"20%"
}
, { field:
"Code"
, title:
" "
, filterable:
false
, template:
"<input type='button' class='k-button k-button-send' value='Details' onclick='showDetails(\"#=Code#\")'/>"
}
]
}).data(
"kendoGrid"
);
}
function
showDetails(code) {
var
windowElement = $(
"#window"
);
if
(!windowElement.data(
"kendoWindow"
)) {
windowElement.kendoWindow({
width:
"600px"
,
height:
"400px"
,
title:
"TESTING"
,
modal:
true
,
resizable:
false
,
//close: onClose,
close:
function
(e) {
// destroy window
this
.destroy();
},
actions: [
"Close"
],
content: {
url:
'shareDetail.html'
,
data: {
op: code
}
}
});
}
}
</script>
If someone can help me, I would be really grateful.
Thanks,