[英]Javascript - Retrieve Data from the DOM
I am trying to get data from the DOM using Javascript. 我正在尝试使用Javascript从DOM中获取数据。
My tree is: this.caseCodingList.grid.store.__proto__.index
我的树是:
this.caseCodingList.grid.store.__proto__.index
I need to retrieve one of the IDs from the index. 我需要从索引中检索ID之一。 It doesn't matter which.
没关系。 Here are various things I have tried, but failed on.
这是我尝试过的各种尝试,但失败了。
Attempt One: 尝试一:
var grid = this.caseCodingList.grid;
var row = grid.store.getPrototypeOf(data).get(0);
Attempt Two: 尝试二:
var row = grid.store.getData();
Attempe Three: 尝试三:
var index = grid.store.__proto__.index
This one does return something, but I am not able to extract what I want. 这个确实返回了一些东西,但是我无法提取我想要的东西。 I also don't know if it will be cross browser compatible.
我也不知道它是否将与跨浏览器兼容。 I am developing mainly with Chrome.
我主要使用Chrome进行开发。 Results:
结果:
{871: 3, {A9A1B512-8E93-4131-B9CD-85C1AEF04722}: 0, {C249D8F2-4561-4657-A6CF-039C0DC89898}: 1, {82FDAFEA-6DCC-483C-BEB7-DDF37818A4C5}: 2}
Any suggestions? 有什么建议么? Thanks!
谢谢!
const index = grid.store.index;
const idOfObjectWithZeroEntries = Object
.keys(index)
.find(x => index[x] === 0);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.