簡體   English   中英

由於嘗試進入此功能csvDownload,因此出現錯誤

[英]I am getting an error since I tried to move into this function csvDownload

  • 我正在嘗試從網格下載文件。
  • 當我單擊“打開第一個”窗口鏈接時,將彈出一個彈出窗口。
  • 在該彈出窗口中,您將看到一個網格。
  • 但是現在由於嘗試移入此功能而出現錯誤

csvDownload Uncaught SyntaxError:意外的令牌<。

  • 我正在嘗試像樣本原型小提琴一樣下載文件。
  • 你們能告訴我如何解決它嗎?請在下面提供我的代碼

樣本原型http://jsfiddle.net/khfL1jsh/

未捕獲的SyntaxError:意外的令牌<不起作用http://jsfiddle.net/2s79mnq5/

template: function csvDownload() {
        //return "testing" + that.FinancialDocuments.ImageType(model);
        <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);
      }

我已經修改了JS文件,現在至少沒有觸發該錯誤。

看一看:

$("#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();
  });
});

這是更新的小提琴: http : //jsfiddle.net/2s79mnq5/#&togetherjs=CVveJp1NKp

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM