


How to export and add information to AngularJS tables? I'll tell you in a few minutes about the process of exporting messages from angularjs tables
This article mainly talks about the problem of adding additional information to angularjs table export. This article includes the whole process of angularjs table export information. I hope it will be useful to everyone. , now let’s look at this article together
Original command
Original exportExcel
command, AngularJS exports Excel instructions.
#This is the user's demand. When an organization applies for calibration of instruments, it can apply for the calibration of multiple instruments at one time. The personnel of the technical agency will get the printed form. Contact the department for verification, so the form should contain the form information of the appliance, as well as the applicant unit, contact number and other information.
Just finished reading the official document. Without affecting the use of the original command, we can set an optional extraData
parameter. If this parameter is passed in, put this To the head of the table, if it is not passed in, it is compatible with the original instruction and the table will be output according to the original method. (If you want to see more, go to the PHP Chinese website angularjs Learning Manual to learn)
Complete the command
Add a parameter to the commandextraData
, binding Add ?
to the mode to indicate that the attribute is optional
scope: { extraData: '=?', // = 双向绑定,?表示该属性可选 tableId: '@', // 表格id exportCols: '@', // 表格导出的列数,为了解决编辑删除按钮的问题,如果全部导出会将编辑删除的代码一并导出 multipleRowCols: '@', // 表格中有效数据跨行的列数,添加空,用于显示跨行效果 noMultipleRowCols: '@', // 整个表格中不跨行的列数,用户判断该行为正常行还是跨行行 csvName: '@' // 导出表格名称 }
Data structure design
Because all the additional information to be added needs to be passed in one item, this is the best place The data structure should be Map
.
// 如果传入了extraData的话,表示有额外的数据,添加到表格头 if (scope.hasOwnProperty('extraData')) { // foreach传入的map scope.extraData.forEach(function(value, key) { // 对于null/undefined的数据采用空字符替换 let tempValue = value ? value : ''; // 拼接到数据中 csvString = csvString + key + "," + tempValue + "\n"; }); }
Traverse Map
, splice key-value pairs, and add a newline each time through the loop.
BuildMap
// 生成额外的数据信息,用于Excel导出使用 self.generateMapForExcelExtraData = function() { var map = new Map(); map.set('申请日期', $filter('date')($scope.work.apply.applyTime)); map.set('申请单位', $scope.work.apply.department.name); map.set('申请人', $scope.work.apply.createUser.name); map.set('联系电话', $scope.work.apply.createUser.mobile); map.set('检定场所', $scope.work.apply.checkPlace); map.set('申请备注', $scope.work.apply.remarks); map.set('申请ID', $scope.work.apply.id); map.set('受理部门', $scope.work.apply.auditingDepartment.name); map.set('受理人', $scope.work.apply.auditingUser.name); map.set('受理人电话', $scope.work.apply.auditingUser.mobile); map.set('计划检定日期', $scope.work.apply.plannedCheckDate); map.set('受理备注', $scope.work.apply.replyRemarks); $scope.extraData = map; };
Achievement effect:
This article ends here That’s it. (If you want to see more, go to the PHP Chinese website angularjs learning manual to learn). If you have any questions, you can leave a message below and ask questions
The above is the detailed content of How to export and add information to AngularJS tables? I'll tell you in a few minutes about the process of exporting messages from angularjs tables. For more information, please follow other related articles on the PHP Chinese website!

JavaScript core data types are consistent in browsers and Node.js, but are handled differently from the extra types. 1) The global object is window in the browser and global in Node.js. 2) Node.js' unique Buffer object, used to process binary data. 3) There are also differences in performance and time processing, and the code needs to be adjusted according to the environment.

JavaScriptusestwotypesofcomments:single-line(//)andmulti-line(//).1)Use//forquicknotesorsingle-lineexplanations.2)Use//forlongerexplanationsorcommentingoutblocksofcode.Commentsshouldexplainthe'why',notthe'what',andbeplacedabovetherelevantcodeforclari

The main difference between Python and JavaScript is the type system and application scenarios. 1. Python uses dynamic types, suitable for scientific computing and data analysis. 2. JavaScript adopts weak types and is widely used in front-end and full-stack development. The two have their own advantages in asynchronous programming and performance optimization, and should be decided according to project requirements when choosing.

Whether to choose Python or JavaScript depends on the project type: 1) Choose Python for data science and automation tasks; 2) Choose JavaScript for front-end and full-stack development. Python is favored for its powerful library in data processing and automation, while JavaScript is indispensable for its advantages in web interaction and full-stack development.

Python and JavaScript each have their own advantages, and the choice depends on project needs and personal preferences. 1. Python is easy to learn, with concise syntax, suitable for data science and back-end development, but has a slow execution speed. 2. JavaScript is everywhere in front-end development and has strong asynchronous programming capabilities. Node.js makes it suitable for full-stack development, but the syntax may be complex and error-prone.

JavaScriptisnotbuiltonCorC ;it'saninterpretedlanguagethatrunsonenginesoftenwritteninC .1)JavaScriptwasdesignedasalightweight,interpretedlanguageforwebbrowsers.2)EnginesevolvedfromsimpleinterpreterstoJITcompilers,typicallyinC ,improvingperformance.

JavaScript can be used for front-end and back-end development. The front-end enhances the user experience through DOM operations, and the back-end handles server tasks through Node.js. 1. Front-end example: Change the content of the web page text. 2. Backend example: Create a Node.js server.

Choosing Python or JavaScript should be based on career development, learning curve and ecosystem: 1) Career development: Python is suitable for data science and back-end development, while JavaScript is suitable for front-end and full-stack development. 2) Learning curve: Python syntax is concise and suitable for beginners; JavaScript syntax is flexible. 3) Ecosystem: Python has rich scientific computing libraries, and JavaScript has a powerful front-end framework.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Chinese version
Chinese version, very easy to use

WebStorm Mac version
Useful JavaScript development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver Mac version
Visual web development tools
