DynamicForm initialCriteria not filtering

Hi, I recently discovered this product and it looks great, thanks for all the effort you’ve put into it!
I’m tring to build my first app and hit a problem that i simply cannot get to work, and I’m certain it’s just something basic that I’m missing somehow, I’d greatly appreciate a minute of your time so set me straight.
The problem is that I can’t get a DynamicForm using a RestDataSource to apply a filter. I’ve read the docs and this forum, and it seems like it should be a no-brainer - simply use initialCriteria, but I can’t get it to work! I tried filterData also with no luck. The form always comes up populated with the 1st row of the datasource instead of the row identified by the criteria (id 28 in the example) PLEASE tell me what I’m doing wrong..
This is the very simple code I’m using:

isc.RestDataSource.create({
    ID: "memberDS",
    dataFormat:"json",
    titleField:"last_name",
    title:"Member",
    fetchDataURL:"get_data.php?tbl=member",
    addDataURL:"put_data.php?tbl=member",
    updateDataURL:"put_data.php?tbl=member",
	removeDataURL:"put_data.php?tbl=member",
    fields:{
        id:{
            title:"id",
            primaryKey:true,
            hidden:true,
            type:"integer",
	    required:true,
            length:20,
            name:"id"
        },
        username:{
            title:"Username",
            type:"text",
  	    required:true,
            length:20,
            name:"username"
        }
})
isc.DynamicForm.create({
    dataSource:memberDS,
    ID:"form0",
//	filterData:{id:28},
	initialCriteria:{id:28},
    autoDraw:true,
    autoFetchData:true
})
isc.VLayout.create({
	ID:"VLayout0",
    members:[
        form0
    ],
    autoDraw:true,
    overflow:"hidden",
    width:"100%",
	height:"100%"
})

PS. one other question - i’m defining all of the datasources in seperate js files and am currently using script src tags to include them in my apps main page, could you please tell me the best practice method of placing/referencing these datasources?

Thanks again for the great job!

Hi raysinhell,

Those settings should cause a request to get_data.php passing ?id=28 in the URL - at that point the server needs to return just the single identified record. Make sense?

As far as the DataSources, that’s fine for now, you might consider combining them into a single file when you actually deploy the application.

Thanks

Yes that makes sense, thanks. The reason I thought it was working differently was because I thought it was filtering on the client side, but in this case server side filtering is fine. Would you have a quick tip for the best practice to do apply a client side filter?

It kicks in automatically for small datasets, see the SmartClient docs for ResulltSet. In this case however, the form can only meaningfully work with one record, so it expects that the server will only send one.

A common pattern is to connect a grid that is viewing multiple records with a form for editing the selected one, by calling editSelectedData().