is there a way to set the unique id of a page component in javascript?
I'm opening a drawer through the multiple actions option on my table, and in the drawer I'm creating a line graph using Highcharts that represents data from the record on the table.
Everything works great with one catch:
Because I have to create a division with a unique id to cast my chart into, I'm running into an issue where if I open a drawer, and then immediately open a second without closing the first both graphs now show the data for the second record instead of their appropriate graph.
The bug gets worse the more drawers I open.
My question is: Is it possible to locate the control I want in javascript, and programmatically change it's unique id so that no other drawers will overwrite the graph in the first drawer. I would like to set the id using information from the context row that I know won't be duplicated.
Everything works great with one catch:
Because I have to create a division with a unique id to cast my chart into, I'm running into an issue where if I open a drawer, and then immediately open a second without closing the first both graphs now show the data for the second record instead of their appropriate graph.
The bug gets worse the more drawers I open.
My question is: Is it possible to locate the control I want in javascript, and programmatically change it's unique id so that no other drawers will overwrite the graph in the first drawer. I would like to set the id using information from the context row that I know won't be duplicated.
Tagged:
1
Categories
- 7.9K Questions
- 926 Ideas
- 220 Discussion Categories
- 178 General
- 9 Community Feedback
- 3 Community Info
- 18 Knowledge Base
Comments
No need for js.
https://community.skuid.com/skuid/topics/skuid-line-graph-question
<code>
$('#container').highcharts({
title: 'Monthly Usage',
chart: {
renderTo: document.getElementById("#container")
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
yAxis: {
title: {text: 'Usage'}
},
plotOptions: {
series: {
type: "line"
}
},
series: [{
name: iqModelRow.Utility_Account_Number__c,
data: [iqModelRow.Jan_Load__c, iqModelRow.Feb_Load__c, iqModelRow.Mar_Load__c, iqModelRow.Apr_Load__c,
iqModelRow.May_Load__c, iqModelRow.Jun_Load__c, iqModelRow.Jul_Load__c, iqModelRow.Aug_Load__c,
iqModelRow.Sept_Load__c, iqModelRow.Oct_Load__c, iqModelRow.Nov_Load__c, iqModelRow.Dec_Load__c]
}]
});
</code>
If there were a way to just plug datapoints of a single record into a skuid line chart I wouldn't have this issue I think.
Our organization has one object with a record for each month that I needed a line graph representation of.
I created an additional model that I update with the Context Row record
I created a row action that opened a drawer
Placed a skuid chart in that drawer
and used a before render snippet to fill it with what was needed:
below is the snippet I used, hope this helps someone in the future.
<code>
var params = arguments[0], $ = skuid.$;
var intake = skuid.$M('modelContainingContextRowRecord').getFirstRow();
//add intake data as series in params object which is the chart we are rendering.
//also setup the x axis value labels and the y axis label
var chart = params;
var newSeries = [{
name: intake.Account_Number__c,
data: [intake.Jan_Data__c, intake.Feb_Data__c, intake.Mar_Data__c,
intake.Apr_Data__c, intake.May_Data__c, intake.Jun_Data__c,
intake.Jul_Data__c, intake.Aug_Data__c, intake.Sept_Data__c,
intake.Oct_Data__c, intake.Nov_Data__c, intake.Dec_Data__c]
}];
chart.xAxis[0].categories = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec'];
chart.series = newSeries;
</code>
This question is now Answered, I am not sure how to mark it as such though.