read field from resultSet

Hi,

Is this right way to read fields? fields name: ID, StartTime, Description

thanks!
steven

	setDataSource :function (ds)
	{
		this.ds = ds;		
		this.data = isc.ResultSet.create({
         dataSource : ds
        })
	},
	fetchData : function ()
	{
		this.count = this.data.getLength();
        for (var i = 0; i < this.count; i++) {
            var appointment = isc.IButton.create({
                ID:"schedule_" + this.data.get(i)["ID"],
                title: this.data.get(i)["StartTime"],
                desc: this.data.get(i)["Description"]
            });
            isc.logWarn(appointment.thisDate);
        }
          		
	},

Easier than that:

        for (var i = 0; i < this.count; i++) {
            var record = this.data.get(i);
            var appointment = isc.IButton.create({
                ID:"schedule_" + record.ID,
                title: record.StartTime,
                desc: record.Description
            });
        }

it seems that this.data.get(i) doesn’t return any record. The datasource is tested in listGrid with successful result. Is there any module to load beside databinding?

ResultSets load data asynchronously, that may be the problem you’re having. You can use the dataArrived() notification to find out when data has loaded.

the datasource is a local datasource like this

	results = isc.DataSource.create({
			ID: "ds",
			clientOnly: true,
	        testData : t_data,
	        fields : ifields
	    });

do you have a sample code to use dataArrived?

thanks!

Hi xwang,

dataArrived works like any other SmartClient method, however, you would probably find the GridPager example very useful, it’s very similar to what you’re trying to do - or may be exactly what you’re trying to do :slight_smile:

called dataArrived like

			this.count = this.data.getLength();
			this.fieldArray = new Array();
			this.data.dataArrived(0,this.count);

this.data is a resultset.

get an error message in log:

7:49:03.485:XRP2:INFO:xmlSelect:selectNodes: expression: //default:return returned Array[3]: 0ms
07:49:03.500:XRP2:INFO:ResultSet:isc_ResultSet_273:creating auto-operation for operationType: fetch
07:49:03.516:XRP2:INFO:ResultSet:isc_ResultSet_273:setCriteria: filter criteria unchanged
07:49:03.532:XRP2:WARN:Log:TypeError: this.data.dataArrived is not a function

that is a good grid component, but not what I work on. I try to put appointments on a calender like outlook. The function iterates the datasource/resultset and display the appointment at the right spot.

Do you have sample code to read from resultset or datasource directly?

thanks!

Hi xwang,

We directed you to look at the GridPager example not in order to use the actual GridPager component, but to see how it is implemented. It demonstrates correct use of dataArrived and other APIs.

dataArrived function?
I don’t see that in gridPager.jsp.

In the same thread, call this.data.getLength(), it returns 1000 which should be 3. There are 3 records in the datasource.

got clue from other thread

the issue is closed.