Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8301585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:00:51+00:00 2026-06-08T17:00:51+00:00

I have a string as var str = ‘Supplier Name^supplier^left^string*Spend (USD MM)^spend^right^number^5’; I write

  • 0

I have a string as

var str = 'Supplier Name^supplier^left^string*Spend (USD MM)^spend^right^number^5';

I write a function in javascript to retrieve the datafield names from the above string and store it in an array as :

        function getColNamesfromConfig(str) {
        var cols = new Array();
        for (i = 0; i <= str.split('*').length - 1; i++) {
            cols[i] = str.split('*')[i].split('^')[1];
            //Will write logic to retrieve the Supplier Name, Spend (USD MM) fields etc
        }
        return cols;
    }

The result i get is as :
cols[0] = supplier;
cols[1] = spend; and so on..(which are datafields)

Then i make a dynamic table and use the above info retrieved as :

"onResultHttpService": function (result, properties) {

            var json_str = Sys.Serialization.JavaScriptSerializer.deserialize(result);


            var colNames = getColNamesfromConfig(properties.PodAttributes.DGConfig);
            var htmlMarkup = '';


            htmlMarkup = "";                
            htmlMarkup = htmlMarkup + "<table width='100%' border='1' cellspacing='0' cellpadding='0' class='gridView gridMouseOverEffect'>";
            htmlMarkup = htmlMarkup + "<tr>";

            for (var c = 0, colLen = colNames.length; c < colLen; c++) {
             //COLUMN LOOP (here i want to bind 'Supplier Name' and not 'supplier' which is what i get from getColNamesfromConfig(str);
                htmlMarkup = htmlMarkup + "<th align='left' class='secondaryLink tableContentRow'> <h5>" + colNames[c] + "</h5>";
                htmlMarkup = htmlMarkup + "</th>";
            }
            htmlMarkup = htmlMarkup + "</tr>";

            for (var i = 0, rowlen = json_str.length; i < rowlen; i++) {
                htmlMarkup = htmlMarkup + " <tr>"

                for (var c = 0, colLen = colNames.length; c < colLen; c++) {
                    htmlMarkup = htmlMarkup + " <td align='left' class='secondaryLink tableContentRow'>   " + json_str[i][colNames[c]];
                    htmlMarkup = htmlMarkup + "</td>"
                }
                htmlMarkup = htmlMarkup + "</tr>"
            }
            htmlMarkup = htmlMarkup + "</table>"
            divPortletId = '#' + properties.id;
            $(htmlMarkup).appendTo($(divPortletId));

        }

If i had to retrieve the Display Name as well from the sample string how would i store it in the same array and access it?. For ex: i want something where i can just loop and get my Display Name (Supplier Name) and also datafield name (supplier). I just want to bind the Display name in my COLUMN LOOP where it is currently binding the column data field. Thus please help me TWEAK my getColNamesfromConfig(str) function to return both the datafield as well as displayname in an array or an object literal if possible..I need something like

cols[0].DisplayName = "Supplier Name";
cols[0].DatafieldName = "supplier";
cols[1].DisplayName = "Spend (USD MM)";
cols[1].DatafieldName = "spend";
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T17:00:53+00:00Added an answer on June 8, 2026 at 5:00 pm
    function getColNamesfromConfig(str) {
        var cols = new Array();
        for (i = 0; i <= str.split('*').length - 1; i++) { 
            cols[i] = {}
            cols[i].DatafieldName = str.split('*')[i].split('^')[1]; 
            cols[i].DisplayField = str.split('*')[i].split('^')[0];
        }
        return cols;
    }
    

    That should do the trick

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following situation: function Mach3Code(Str: String): String; var StrOut: String; begin StrOut
I have the following code in AS3: var str:String = '<TEXTFORMAT LEADING=2><P ALIGN=LEFT><FONT FACE=Arial
i have a string like var str='<input type=text name=se_tbox value=Beauty is Fake />'; I
Let's say I have a string like this: var str = /abcd/efgh/ijkl/xxx-1/xxx-2; How do
HI I have a URL var str:String = conn=rtmp://server.com/service/&fileId=myfile.flv or var str:String = fileId=myfile.flv&conn=rtmp://server.com/service/
What is the opposite of String.charAt() ?? If I Have a string: var Str:String=Hello
I have a string like this: var str = I'm a very^ we!rd* Str!ng.;
I will have a string like below var str = -#A This text belongs
I have a string. It's just like; var str = This is an example
I have string like this var str = #it itA itB _ #et etA

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.