Home / Blog / YUI Datatable note: the initialRequest string is appended to the datasource url

History always repeats itself and sometimes that's good. Here's a second chance to be part of it: tmdtc.com

YUI Datatable note: the initialRequest string is appended to the datasource url

YUI2's Datatable is a great widget I use in MyOwnDB and here's a small tip for when you use it to load a remote data source .

In that case, the datatable is getting the data to display from a YUI2 DataSource that has been configured with the URL to use when fetching the data requested by the datatable.

When instanciating the datatable, you can pass it a configuration object, with amongst other option, the initialRequest that should be sent by the associated datasource when the datatable is displayed for the first time. initialRequest is a string that is simply appended to the URL passed to the DataSource.

So if your datasource URL is "http://www.myurl.com?all=true", and your initialRequest is "sort=name", the request sent by the DataSource will be for the URL "http://www.myurl.com?all=truesort=name", which is clearly not good.

The solution here is to either be sure that the datasource URL ends with a ? or a &, or to always start the initialRequest with &.

The second option is the easiest in my case.

Commentaires

%login_link_starAuthentifiez vous ou créez un nouveau compte utilisateur pour commenter.

Disponible pour intervention 

Si vous recherchez quelqu'un pour renforcer temporairement votre équipe ou si vous avez besoin d'aide pour que l'IT aide votre société, n'hésitez pas, contactez-moi !

Lun Mar Merc Jeu Ven Sam Dim
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31