例如我有以下数据,
var expectedValuesObj = [ "a.com","testid1","200.00" ];
var actualValuesObj = [
["a.com","testid1","200.00"],
["a.com","testid1","200.00"],
["a.com","testid1","200.00"],
["b.com","testid2","200.00"],
["a.com","testid1","200.00"],
["c.com","testid1","200.00"],
["a.com","testid1","400.00"],
["a.com","testid1","200.00"],
["a.com","testid1","200.00"]
];
通过使用上述数据,我需要将数据与expectedValuesObj与actualValuesObj进行比较,这些对象中的每个值,如果发现任何不匹配,那么我必须突出显示与expectedValuesObj不匹配的记录。
例如,在expectedValuesObj[0]中,我将与actualValuesObj[0]进行比较
,我没有发现任何不匹配,因为
actualValuesObj[0] = ["a.com","testid1","200.00"]
所有值都与expectedValuesObj[0] = ["a.com","testid1","200.00"]
. 记录
如果发现任何记录不匹配,那么我必须突出显示该记录。
我更喜欢使用 js、bootstrap、jquery、dataTables 和 laodash 的任何好的建议和想法。
注意:为了比较两个数据集,如果您愿意,可以根据自己的喜好更改 dataFormat,如果您觉得给定的 dataSet 不具有可比性。
主页.html
<html>
<body>
<div id="conatiner"> This Div will have DataTable rendered by below js script file i.e File1.js , And this will Contain the child rows as well which will have the href link and I will open the new window on click of that link , it will open the mainPage2.hmtl with File2.js loaded .</div>
</body>
<th layout:fragment="page-specific-js" th:remove="tag">
</html>
mainPage2.hmtl
<html>
<body>
<div id="conatiner"> Here I want render the Data which is mismatched and and I have to highlight. </div>
<script th:src="@{/resources/build/js/File2.js(v=${startUpTime})}" />
</th>
</body>
</html>
所以我期望比较和突出显示的逻辑可以在 File2.js 中。
文件1.js
// Here I'm importing the jQuery data tables lib's
// implemented the script to display the Table with child rows in mainPage1.html
// I guess not necessary to add all the logic and DataTable formation here because it's a general syntax.
文件2.js
var expectedValuesObj = [ "a.com","testid1","200.00" ];
var actualValuesObj = [
["a.com","testid1","200.00"],
["a.com","testid1","200.00"],
["a.com","testid1","200.00"],
["b.com","testid2","200.00"],
["a.com","testid1","200.00"],
["c.com","testid1","200.00"],
["a.com","testid1","400.00"],
["a.com","testid1","200.00"],
["a.com","testid1","200.00"]
];
// By using the above object after comparison, I want to display it in mainPage2.html by highlighting the mismatch records.