HI, I was wondering what the difference in the YUI DataTable API is between these 2 functions: 1. oColumn.getKey() 2. oColumn.getField() I did an alert of both

Message 2 of 7
, Jan 4, 2010

0 Attachment

HI,

I was wondering what the difference in the YUI DataTable API is between these 2 functions:1. oColumn.getKey()2. oColumn.getField()

I did an alert of both of these and was getting the same strings returned.

Thanks!

Satyam

... In the same API you can see that the column has properties field and key and this methods reflect that, more or less. The properties of the Column are

Message 3 of 7
, Jan 4, 2010

0 Attachment

El 04/01/2010 18:09, Eric Cire escribió:

HI,

I was wondering what the difference in the YUI DataTable API is between
these 2 functions:
1. oColumn.getKey()
2. oColumn.getField()

I did an alert of both of these and was getting the same strings
returned.

Thanks!

In the same API you can see that the column has properties field and
key and this methods reflect that, more or less. The properties of the
Column are those you set via the columns definitions when you set the
table description.

While all columns need to have a key value to identify themselves, and
that key usually corresponds to the incoming field names in the
DataSource.responseSchema.fields array, it doesn't need to be so. The
column can have a key value and you can use the field property to tell
which field to use for that column. If you don't provide a field,
DataTable will use key, which is what most people do.

If you are using a JSON data source and used dot notation to access
deeply nested fields, your fieldnames are going to be very long, that
is when you might want to think of using different field and key values
so you can still keep key short.

If you don't provide a value for the field property, it will remain
null, however, the getField() method will then return the key value,
that's why I said "more or less", because field might be null and
getField will return, as in your case, the same value that getKey
returns.

Satyam

Christian Tiberg

Wow, that was some great info right there. I ve been taking pains to get everything to the top level in my JSON responses, now I won t have to - thanks! Best

Message 4 of 7
, Jan 5, 2010

0 Attachment

Wow, that was some great info right there. I've been taking pains to get everything to the top level in my JSON responses, now I won't have to - thanks!

I was wondering what the difference in the YUI DataTable API is between
these 2 functions:
1. oColumn.getKey()
2. oColumn.getField()

I did an alert of both of these and was getting the same strings
returned.

Thanks!

In the same API you can see that the column has properties field and
key and this methods reflect that, more or less. The properties of the
Column are those you set via the columns definitions when you set the
table description.

While all columns need to have a key value to identify themselves, and
that key usually corresponds to the incoming field names in the
DataSource.responseSchema.fields array, it doesn't need to be so. The
column can have a key value and you can use the field property to tell
which field to use for that column. If you don't provide a field,
DataTable will use key, which is what most people do.

If you are using a JSON data source and used dot notation to access
deeply nested fields, your fieldnames are going to be very long, that
is when you might want to think of using different field and key values
so you can still keep key short.

If you don't provide a value for the field property, it will remain
null, however, the getField() method will then return the key value,
that's why I said "more or less", because field might be null and
getField will return, as in your case, the same value that getKey
returns.

Satyam

Satyam

It is a recent change and it had a few bugs since some pieces of code that used key were overlooked when dividing its duties between getKey and getField.

Message 5 of 7
, Jan 5, 2010

0 Attachment

It is a recent change and it had a few bugs since some pieces of code
that used 'key' were overlooked when dividing its duties between getKey
and getField. Since really few people even know of their existence,
there have been few test cases and a few things slipped past without
anyone noticing and, though I doubt it, some might still lie hidden.
You might want to check the bug reports just in case.

Here is a perfect example of why a company would care to release its
product as open source. Yahoo on its own would not have the ability to
test this change in all the possible combinations the DataTable
offers. External users provide test cases that nobody else might have
thought about. We shouldn't be shy about reporting an error, that's
the way we contribute.

Satyam

El 05/01/2010 9:43, Christian Tiberg escribió:

Wow, that was some great info right there. I've been taking pains to
get everything to the top level in my JSON responses, now I won't have
to - thanks!

I was wondering what the difference in the YUI DataTable API is between
these 2 functions:
1. oColumn.getKey()
2. oColumn.getField()

I did an alert of both of these and was getting the same strings
returned.

Thanks!

In the same API you can see that the column has properties field and
key and this methods reflect that, more or less. The properties of the
Column are those you set via the columns definitions when you set the
table description.

While all columns need to have a key value to identify themselves, and
that key usually corresponds to the incoming field names in the
DataSource.responseSchema.fields array, it doesn't need to be so. The
column can have a key value and you can use the field property to tell
which field to use for that column. If you don't provide a field,
DataTable will use key, which is what most people do.

If you are using a JSON data source and used dot notation to access
deeply nested fields, your fieldnames are going to be very long, that
is when you might want to think of using different field and key values
so you can still keep key short.

If you don't provide a value for the field property, it will remain
null, however, the getField() method will then return the key value,
that's why I said "more or less", because field might be null and
getField will return, as in your case, the same value that getKey
returns.