Is this the right way to exclude rows with NULL values from the LABKEY.ext.Store ?

LabKey Support Forum (Inactive)
Is this the right way to exclude rows with NULL values from the LABKEY.ext.Store ? Ben Bimber  2012-05-21 18:38
Status: Closed
 
hi leo,

rather than throw a placeholder in the value (  is probably what you'd want), the way you generall accomplish something like this is using custom Ext render tpl:

http://docs.sencha.com/ext-js/3-4/#!/api/Ext.form.ComboBox-cfg-tpl

however, if you use LABKEY.ext.ComboBox there's a build-in way to handle this. On your store, set nullRecord to something like:


                config.nullRecord = {
                    displayColumn: 'myDisplayColumn,
                    nullCaption: "[none]"
                };

this will cause the store to add a placeholder record with a null value and '[none]' as the display value. however, with a LOVCombo, that may not be what you're looking for (multi-select being different than a traditional combo).

next you'd want to explore the tpl of your combo. this is what renders the value. something like:

                    tpl: new Ext.XTemplate(
                        '<tpl for=".">' +
                        '<div class="x-combo-list-item">{[values["' + l.keyColumn + '"]!==null ? values["' + l.displayColumn + '"] : "'+ (Ext.isDefined(this.lookupNullCaption) ? this.lookupNullCaption : '[none]') +'"]}' +
'</tpl>'+
                        '&nbsp;</div></tpl>'
                        )

should do it. that's one was written for the more general case and could be simplified if you have a fixed name for the display/value columns or the null caption. this tpl could also be modified to show more than 1 column, so you could show both the display column and the raw value.