Loading Multi Header Values From CSV File

Hi All,

I wonder if you may assist me here. I've searched the forum and found a couple of threads that are on my topic, however none of the exiting ones quite fit my requirements.

I am using a CSV file, and would like the first two lines of that file to be used as the two grid headers. (I've set obj.setHeaderCount(2);)

Any assistance would be greatly appreciated.

Current code in use detailed below:

<script type="text/javascript">
    var table = new AW.CSV.Table;
    var obj = new AW.Grid.Extended;
    obj.setHeaderHeight(40, 0); // header row-0
    obj.setHeaderHeight(30, 1); // header row-1


March 24,

unfortunately there is no right event to attach to - it is necessary to modify table.response method to achieve what you want.

var table = new AW.CSV.Table;

    table.response = function(text){

        this._rows = text.split(/\r*\n/);
        if (!this._rows[this._rows.length-1]){
        this._data = [];

        if (this.$owner) {
            // grid initialization

            // copy data to grid headers
            var i, max = this.$owner.getColumnCount();
            for (i=0;i<max;i++){
                this.$owner.setHeaderText(this.getData(i, 0), i, 0); // 1st row
                this.$owner.setHeaderText(this.getData(i, 1), i, 1); // 2nd row
            // remove first 2 rows from data arrays
            this._rows.splice(0, 2);
            this._data.splice(0, 2);

            // continue grid initialization

// then as usual...
Alex (ActiveWidgets)
March 24,
Excellent. Thank you very much for your help with this Alex, works perfectly.

March 25,

This topic is archived.

See also:

Back to support forum