Javascript 在UI中表示以下数据并突出显示的最佳方式是什么
例如,我有以下数据Javascript 在UI中表示以下数据并突出显示的最佳方式是什么,javascript,jquery,node.js,datatables,bootstrap-grid,Javascript,Jquery,Node.js,Datatables,Bootstrap Grid,例如,我有以下数据 var expectedValuesObj = [ "a.com","testid1","200.00" ]; var actualValuesObj = [ ["a.com","testid1","200.00"], ["a.com","testid1","200.00"], ["a.com","testi
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和实际值Sobj进行比较,这些对象中的每一个值,如果发现任何不匹配,我必须突出显示与expectedValuesObj不匹配的记录
例如,在期望值sobj[0]中,我将与实际值sobj[0]
,我没有发现任何不匹配,因为
actualValuesObj[0]=[“a.com”、“testid1”、“200.00”]
所有值都与expectedValuesObj[0]=[“a.com”、“testid1”、“200.00”]
匹配。记录
如果发现任何记录不匹配,那么我必须突出显示该记录
我更喜欢使用js、bootstrap、jquery、dataTables和laodash的任何好建议和想法
注意:对于比较两个数据集,如果您认为给定的数据集不可比较,您可以根据自己的喜好更改数据格式。
mainPage.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">
File2.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.
这甚至不是有效的javascript。您的对象缺少属性名。更新了问题,请现在查看。对于您的信息数据格式,您可以根据自己的喜好进行更改。当您说在UI中突出显示时,您是如何显示此内容的?发布你所有的html和js以便我们能提供帮助。现在请检查我已经更新了问题,我跳过了代码,这是一般性的,现在File2.js期待着比较和突出显示的解决方案,你可以使用File2.js和mainPage2.html进行任何操作@适用于
<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>
// 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.
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.