J'ai modifié le fichier JS un peu et maintenant au moins ne déclenche pas l'erreur.
Jetez un oeil:
$("#open1").click(function() {
$("#win1").show().kendoWindow({
width: "500px",
height: "500px",
modal: true,
title: "Window 1"
});
});
//debugger;
$("#open2").click(function() {
$("#win2").show().kendoWindow({
width: "500px",
height: "500px",
modal: true,
title: "Window 2"
}).data("kendoWindow").center();
});
$("#close2").click(function() {
$("#win2").data("kendoWindow").close();
});
$(document).ready(function() {
$('.pai-del-menu').hide();
var cnt = 0;
var grid = $("#grid").kendoGrid({
dataSource: {
data: [{
FileName: '1 Download CSV (via btoa)',
ThreeDots: 'ThreeDots1'
}, {
FileName: '2 Download CSV (via btoa)',
ThreeDots: 'ThreeDots2'
}, {
FileName: '3 Download CSV (via btoa)',
ThreeDots: 'ThreeDots3'
}, {
FileName: '4 Download CSV (via btoa)',
ThreeDots: 'ThreeDots4'
}, {
FileName: '5 Download CSV (via btoa)',
ThreeDots: 'ThreeDots4'
}],
schema: {
model: {
fields: {
FileName: {
type: "string"
},
ThreeDots: {
type: "string"
}
}
}
},
sort: {
field: "FileName",
dir: "asc"
},
pageSize: 10
},
height: 500,
scrollable: true,
sortable: true,
selectable: true,
filterable: true,
pageable: true,
columns: [{
field: "FileName",
title: "File Name",
//template: "<a id=\"sportsDataPlayer\" download=\"download.csv\" type=\"text\/csv\">#= FileName.substring(FileName.lastIndexOf('/')+1) #</a>"
template: function csvDownload() {
//return "testing" + that.FinancialDocuments.ImageType(model);
var htmlString = "<a id=\'sportsDataPlayer\' download=\'download.csv\' type=\'text\/csv\'>#= FileName.substring(FileName.lastIndexOf('/')+1) #</a>"
var csv = "a,b,c\n1,2,3\n";
var data = new Blob([csv]);
var a2 = document.getElementById("sportsDataPlayer");
alert("I am here");
a2.href = URL.createObjectURL(data);
},
field: "ThreeDots",
title: "Last Name",
template: "<span class='deleteRow'>ThreeDots</span>"
}]
}).data("kendoGrid");
//var csv = "a,b,c\n1,2,3\n";
//var data = new Blob([csv]);
//debugger;
//var a2 = document.getElementById("sportsDataPlayer");
//alert("I am here");
//a2.href = URL.createObjectURL(data);
// grid.tbody.parents(".k-grid-content").eq(0).kendoScroller({ useOnDesktop: false });
// Start by hiding the confirmation
$('.testingConfirmation').hide();
// Create a persistent value for the window
var testingWindowVal;
// Listen to save button click
$("#save").click(function() {
// Set the persistent value
testingWindowVal = $("#fname").val();
// Show the dialog
if (testingWindowVal) {
$('.testingConfirmation').show();
}
});
// Listen to yes from the confirmation
$('#deleteDocumentYes').click(function() {
// Update necessary things
grid.dataSource.add({
"FileName": testingWindowVal,
"ThreeDots": "Last Name"
});
$("#fname").val('');
// Remove the value
testingWindowVal = null;
// Hide the dialog
$('.testingConfirmation').hide();
});
// Listen to no from the confirmation
$('#deleteDocumentNo').click(function() {
// Remove the value
testingWindowVal = null;
// Reset the #fname
$("#fname").val('');
// Hide the dialog
$('.testingConfirmation').hide();
});
});
C'est le violon mis à jour: http://jsfiddle.net/2s79mnq5/#&togetherjs=CVveJp1NKp
À première voir que je peux voir quelques fautes de frappe, l'objet que vous essayez de passer au comme modèle est Mauvais formaté et pas valide. – halbano
Lorsque vous essayez d'obtenir l'élément par ID, l'élément n'est pas sur le DOM, cela ne fonctionnerait pas comme vous le pensez. – halbano
@halbano hey mais je ne vois pas le lien dans la grille ... Je veux dire cette valeur '1 Télécharger CSV ... lorsque vous cliquez sur le lien ouvrir la première fenêtre ----------> jsfiddle.net/wL4v15vd/2 –