/    Sign up×
Community /Pin to ProfileBookmark

When it is a number display text center else text left

The numbers with the colors and the numbers with the percentage must center align and the text must left align

Im only getting to center align for the numbers with colors. The numbers with the percentage values must also center align but it still showing left align can anyone tell me whats wrong please. Thanks in advance

[CODE] if (pods[i].data.summaryDetailedStepThroughData !== undefined && pods[i].data.summaryDetailedStepThroughData.length > 0) {

rowspanMax = 0;
for (var l = 0; l < Object.keys(pods[i].data.summaryDetailedStepThroughData).length; l++) {
contentHtml += “<tr>”;

for (var m = 0; m < pods[i].data.columns.length; m++) {

for (var field in pods[i].data.summaryDetailedStepThroughData[l]) {
var rowspan = (pods[i].data.summaryDetailedStepThroughData[l].children !== undefined ? pods[i].data.summaryDetailedStepThroughData[l].children.length : “”);
rowspanMax = Math.max(rowspanMax, rowspan);

if (field === pods[i].data.columns[m]) {

var preFix = pods[i].data.summaryDetailedStepThroughData[l][“sPrefix”] !== undefined ? pods[i].data.summaryDetailedStepThroughData[l][“sPrefix”] : “”;
var postFix = pods[i].data.summaryDetailedStepThroughData[l][“sPostfix”] !== undefined ? pods[i].data.summaryDetailedStepThroughData[l][“sPostfix”] : “”;
var value = pods[i].data.summaryDetailedStepThroughData[l][field];
if (value.toString().substr(0, 3) == “- 1”) {
value = “N/A”;
}
var color = pods[i].data.summaryDetailedStepThroughData[l][field + “_color”];
if (colName[m] === “sLabel” && pods[i].data.summaryDetailedStepThroughData[l].bStepThrough == true) {
value = “<a href=”#” class=”stepthrough”>” + value + “</a>”;
}
color = color !== “” && color !== undefined ? ” <span class=”color” style=”background: #” + color + “”></span>” : ” <span class=”color”></span>”; contentHtml += “<td rowspan1=”” + 1 + “” class=”” + (rowspan !== “” && rowspan > 1 ? “groups” : “”) + ” ” + (!isNaN(value) || (!isNaN(value.toString().substr(1, value.length)) || value == “N/A” || typeof value == Number) ? “text-center” : “text-left”) + “”>” + value + (Number(value) ? preFix : “”) + color + (!isNaN(value) ? postFix : “”) + “</td>”;
if (rowspan > 1) {
var rowspanContent = “<td rowspan1=”” + rowspan + “” class=”” + (rowspan !== “” && rowspan > 1 ? “groups” : “”) + ” ” + (!isNaN(value) || (!isNaN(value.toString().substr(1, value.length)) || value == “N/A” || typeof value == Number) ? “text-center” : “text-left”) + “”>” + value + (Number(value) ? preFix : “”) + color + (!isNaN(value) ? postFix : “”) + “</td>”;
}[/CODE]

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@rootDec 09.2016 — Why can't you have the HTML elements written in to the page with the HTML and just update them through a DOM method with the values and control positioning with CSS...
Copy linkTweet thisAlerts:
@grampiesauthorDec 11.2016 — I cant change the html all the html is build in javascript is there not a way to change it in my code
Copy linkTweet thisAlerts:
@rootDec 11.2016 — Add a style class to it then.
×

Success!

Help @grampies spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...