|
Nick Kerr responded: |
2012-09-05 13:39 |
Hi Scott,
1. We've implemented an experimental feature for ExtJS documentation moving forward that uses JSDuck (thanks to your recommendation). It's not available in production environments but you can access it by turning it on under "Admin Console" > "Experimental Features" > "JavaScript Documentation" in your local instance. When we do have public API wrapped for ExtJS 4+ components we will expose these docs publicly.
2. Currently, the classes found in internal/webapp/extWidgets are not considered part of our publicly supported API and as such I would not recommend using them for production environment apps.
In the case of the Ext4Store I'd recommend using our JavaScript Query API and populating data stores directly.
3. First, I'd recommend trying to use our dependency loading structure implemented in 12.2. See our documentation here. Second, the Ext.Loader will work you just have to ensure to configure it before use. See the Ext 4 docs on Ext.Loader.setConfig().
Thanks,
Nick |
|
slangley responded: |
2012-09-05 18:44 |
Thanks Nick.
Here's an even more detailed Ext JS 4 question then.
I have a proxy configured like so based on your code in the DataViewsPanel.js of the study module:
proxy : {
type : 'ajax',
url : LABKEY.ActionURL.buildURL('query','selectRows.api'),
extraParams : {
schemaName : 'atlas_psl',
queryName : this.gridQueryName,
},
reader : {
type : 'json',
root : 'data'
}
},
This works but I want to modify the data returned from this query before it is rendered in the grid by adding an additional boolean column to each data row based on the contents of one of the returned data columns. That is, I'm going to take the value of one of the returned columns and execute another JavaScript function on it to generate a boolean true or false based on the characteristics of the the passed in value.
How would you recommend I do this?
Should I extend the Ext.data.reader.Json class and override the readRecords() function to throw in my code that generates this additional column?
Should I add a listener on the 'load' event of the Ext.data.Store and place my code there?
Or somewhere else?
I assume whether I should I add my new boolean column to the Ext.data.Model used by the Proxy and Store would depend on the answer to the above.
Thanks.
Scott |
|
Ben Bimber responded: |
2012-09-05 18:57 |
Hi Scott,
If you're willing to dig into it, I recommend making a custom reader. I think it will end up being a lot cleaner. You can pattern after the one used in LABKEY.ext4.Store, which is basically doing the same thing you need. You can also consider convert() on Ext.data.Field, which is also designed to do the sort of thing you describe:
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.Field-cfg-convert
If you end up overriding the reader, I would suggest adding 'requiredVersion: 9.1' to extraParams, in order to return the results as ExtendedSelectRowsResults. This means it will include both a displayValue and value for each field. If you need to display these data, that might end up being important (lookups, for example). |
|
slangley responded: |
2012-09-07 13:59 |
Hi Ben,
I tried overriding the reader and I think that would have worked except for my particular requirements. The function I use to generate a boolean on one of the returned fields needs to make another Ajax request to the server, in particular, the LABKEY.Security.getContainers() function. So I need for that function to finish and pass control to a callback before the reader.readRecords(data) returns its results. Unfortanately, reader.readRecords(data) doesn't want to wait around for that callback to finish. Perhaps if I used the "batching" mechanism of the Ext4 Proxy class I could have made it work there, but that looked a bit complicated.
So what I ended up doing was overriding the private onProxyLoad(operation) function of Ext.data.Store and deferred the execution of most of its statements to occur in the callback of my invocation of the LABKEY.Security.getContainers() function, after first modifying the passed-in records.
If you have more suggestions, let me know.
Thanks.
Scott |
|
Ben Bimber responded: |
2012-09-07 14:07 |
Hi Scott,
Is there any way to avoid needing that separate AJAX request per row? I dont know much about the source data, but if it's SQL based, could you end up w/ a query that joins in the container-related information? If you do need this second AJAX call, it seems like it would be better to do the first query, process it, then do a single second request that gets the other information all at once.
It would help to know more about the application, but it may not be worth digging this deeply into the store. You could in theory do 1 request to get the initial JSON, do whatever conversion you need, then create a simple ArrayStore or JsonStore with the result. If you plan to do commits then the store/proxy/reader is probably your best option. if you're just reading then I think it may not be worth it. |
|
slangley responded: |
2012-09-07 14:17 |
For our app, we want to identify whether the user has read permission on a set of atlas folders - one folder for each protocol - and then display the list of readable protocols as rows in a grid panel to the user. I was able to do this in one query by passing an array with all the container folders to the LABKEY.Security.getContainers() function.
Yes, building up an ArrayStore first to pass into the grid seems like a good alternative. That would avoid the "fragility" of overriding a private method of Ext.data.Store.
And fortunately, we don't have do support modify/saving any records from this grid.
Scott |
|
Ben Bimber responded: |
2012-09-07 14:26 |
hi scott,
i havent tested this, but it's possible you can do your permission testing in SQL using a single filtered query. If the table with the protocols has a container column, LabKey may even do this filtering for you. Otherwise, perhaps you could join the source table to core.containers, then filter on 'container/name is not null' (b/c LabKey would not allow the user to view any records on core.containers where they dont have read permission). not sure if it would work in your case, but something that might be worth considering. |
|
|
|