jQWidgets Forums

jQuery UI Widgets Forums Grid I meed 1page with csv files as a variable

This topic contains 2 replies, has 2 voices, and was last updated by  paulcobben 5 years, 10 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author

  • paulcobben
    Participant

    Hi,

    I need to create a lot of pages with the same grid, but with different csv files as source. But I only want to create one page with the csvfile as a variable.
    E.g. The page will be called as https://site/jqdata.html?source=p329
    Then the source for the grid on that page should be p329.csv

    I’ve tried and searched alot, but cannot get the wanted result.


    Todor
    Participant

    Hello paulcobben,

    You could try to use the following demo, but instead of hard coded url link var url = '../sampledata/nasdaq_vs_sp500.txt'; you could replace the csv file name with variable var url = '../sampledata/' + csvName; which you would get from URL query param on page load.

    Let us know if you need further assistance.

    Best Regards,
    Todor

    jQWidgets Team
    https://www.jqwidgets.com


    paulcobben
    Participant

    Thanks Todor,

    After a lot of searching I have solved it in another way:

    	    function findGetParameter(parameterName) {
    			var result = null,
    				tmp = [];
    			location.search
    				.substr(1)
    				.split("&")
    				.forEach(function (item) {
    				  tmp = item.split("=");
    				  if (tmp[0] === parameterName) result = decodeURIComponent(tmp[1]);
    				});
    //			document.getElementById("insert").innerHTML = tmp;
    			return result;
    			}
            $(document).ready(function () {
                // prepare the data
     			var source1 =
                {
                    datatype: "csv",
                    datafields: [
                        { name: 'ImageID',       type: 'string' },
    					{ name: 'Variant',       type: 'string' },
    					{ name: 'Groep',         type: 'string' },
    					{ name: 'SubVersion',    type: 'string' }
    					
                    ],
                    url: "Data/p" + findGetParameter( "package" ) + ".CSV",
    
    
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.