简体   繁体   English

Bootstrap表更新结果

[英]Bootstrap Table renewal the result

I am using Bootstrap Table 我正在使用Bootstrap表

I used this function said in tutorial 我在教程中使用了此功能

function (e, value, row, index)

which is i only use is row and index 我只用的是rowindex

now when i retrieve the data using this 现在,当我使用此检索数据时

console.log(row);

the result is 结果是

Object {position: "", username: "test@liferay.com", division: "", status: "1", usertype: ""} 2

Question is how to retrieve all data in different variable or to array 问题是如何检索不同变量或数组中的所有数据

i tried using this way 我试图用这种方式

for (var i in row) {
   console.log(row[i]);
}

the result is 结果是

""
"test@liferay.com"
""
"1"
""

Update 更新

I just want to pass all data from row to new variable to retrieve them. 我只想将所有数据从row传递到新变量以进行检索。

i try to output this way console.log(row[2]); 我尝试以这种方式输出console.log(row[2]); result is undefine 结果undefine

Your variable row is an object , so you need to specify the name to get the value : 您的变量row是一个object ,因此您需要指定名称以获取值:

For example, to get the username, you need : 例如,要获取用户名,您需要:

row.username

If you really need to convert your object into an array, you can use map : 如果确实需要将对象转换为数组,则可以使用map

var obj = {
    position: "",
    username: "test@liferay.com",
    division: "",
    status: "1",
    usertype: ""
};
var arr = Object.keys(obj).map(function (key) {return obj[key]});
console.log(arr[1]);

JSFiddle: http://jsfiddle.net/0985eLg8/ JSFiddle: http : //jsfiddle.net/0985eLg8/

I did this way thanks @Magicprog.fr 我这样做是因为@ Magicprog.fr

var results = JSON.stringify(row);
console.log('results are' + results);
var obj = $.parseJSON(results);
console.log(obj.username);

Giving me exact answer 给我确切的答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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