简体   繁体   中英

Javascript - Retrieve Data from the DOM

I am trying to get data from the DOM using Javascript.

My tree is: this.caseCodingList.grid.store.__proto__.index

I need to retrieve one of the IDs from the index. 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. 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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM