jQWidgets Forums
jQuery UI Widgets › Forums › Grid › How to get 'getcellvalue' dynamically?
This topic contains 5 replies, has 2 voices, and was last updated by Ivo Zhulev 8 years, 4 months ago.
-
Author
-
Hi 🙂
I made jqxGrid.
I want to change my data and export it to excel.
But as Peter Stoev said, if data is redered, we need to change it again in Array of row data.
http://www.jqwidgets.com/community/topic/export-data-with-cellsrenderer-value/I write this code but I can’t get cellvalue of dynamically get datefield.
var gridRows = $jqxGrid.jqxGrid('getrows'); var df = "tQty" + j; var value = $jqxGrid.jqxGrid('getcellvalue', i, df); console.log("gridRows[0].df :" + value + "); // gridRows[0].df : undefined
How can I get df value??
Ah, my code was not right.
Sorry I found “tQty” + 1 is working 🙂How can I edit my before question………..?
I got a problem. That is different.
How can I change tQty1 value to “2222” using df?var df = "tQty" + 1; gridRows[0].tQty1 = "1111"; gridRows[0].df = "2222"; console.log(gridRows[0].tQty1); // "1111"; console.log(gridRows[0].df); // "2222"
Hi soojung,
Can you tell me do you mean the ‘df’ variable or the ‘df’ property?
If it is the variable is the thing you wrote giving you the result you want?
var df = "tQty" + 1; === "tqty1"
If it is the variable and you want to change
gridRows[0].tQty1
to ‘2222’ then ‘df’ variable must be equal to ‘2222’.
So if it is the ‘df’ variable justgridRows[0].tQty1 = df;
.Do I get you right?
Best Regards,
IvojQWidgets Team
http://www.jqwidgets.com/Hi Ivo!
yes, df means variable in my code.My original question was this.
I wanted to make one function that make property dynamically.
For example, if I want to set value to property, I need to write this.var j = 0; for (var i = 0; i < len; i++) { gridRows[i].tQty1 = resultArr[j]; j++; gridRows[i].tQty2 = resultArr[j]; j++; gridRows[i].tQty3 = resultArr[j]; j++; gridRows[i].tQty4 = resultArr[j]; j++; gridRows[i].tQty5 = resultArr[j]; j++; gridRows[i].tQty6 = resultArr[j]; j++; gridRows[i].tQty7 = resultArr[j]; j++; gridRows[i].tQty8 = resultArr[j]; j++; gridRows[i].tQty9 = resultArr[j]; j++; gridRows[i].tQty10 = resultArr[j]; j++; gridRows[i].tQty11 = resultArr[j]; j++; ... gridRows[i].tQty30 = resultArr[j]; j++; gridRows[i].tQty31 = resultArr[j]; j++; }
I thought this is possible. hhh
for (var i = 0; i < len; i++) { for (var j = 0; j < 31; j++) { var tqty = "tQty" + j; gridRows[i].tqty = resultArr[j]; j++; } }
Hi soojung,
You could try with that approach:
let tqty = "tQty" + i; gridRows[i][tqty] = resultArr[j];
Best Regards,
IvojQWidgets Team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.