I have an issue related to the data filtering. I have a Google Drive table to store data, and I want to show one field of this data source in a dropdown to make a filter by this field (Country).
The problem is that this dropdown filter it's only showing the countries that appears on the current page of the list. For example, if in the first page appears one country (Thailand) on the dropdown I'll only see Thailand.
If we move to the second page of the list we have another two countries (Spain and Portugal) and then the dropdown will only show Spain and Portugal.
What I really want is a dropdown which shows all the countries, no matter if they aren't on the current page, but I don't know how to fix it. โ
โThis the the configuration of the Country Selector:
In the help, it's said we should use #datasource.model.fields.COUNTRY.possibleValues,
but if I use this paramater as Options, nothing is displayed in the selector.
I have spend a lot of hours trying to fix this issue and I don't find the solution, and I would like to check with you if it's an issue or I'm doing something wrong...
Could you help me?
You are using the same datasource for your dropdown and table and by #distinct()#sort() you are filtering items that are already loaded to browser (opposed to the whole dataset stored in database).
You need to have a separate datasource for your dropdown. There are at least three techniques to do this:
Possible values
You can predefine allowed values for your Country field and use them to populate drop down options both in create form and table filtering #datasource.model.fields.Country.possibleValues as you mentioned in question:
Create model for countries
By introducing dedicated related model for countries you can get the following benefits:
normalized data (you will not store the same country multiple times)
you'll be able to keep your countries list clean (with current approach there is possibility to have the same country with different spellings like 'US', 'USA', 'United State', etc)
app users when they create new records will be able to choose the country they need from dropdown (opposed to error prone typing it every time for all new records).
your dropdown bindings will be as simple as these:
// for names
#datasources.Countries.items..Names
// for options
#datasources.Countries.items.._key
// for value
#datasource.query.filters.Country._key._equals
Create Calculated Model
With Calculated Model you'll be able to squeeze unique country values from your table. You server query script can look similar to this:
function getUniqueCountries_() {
var consumptions = app.models.Consumption.newQuery().run();
var countries = [];
consumptions.reduce(function (allCountries, consumption) {
if (!allCountries[consumption.Country]) {
var country = app.models.CountryCalc.newRecord();
country.Name = consumption.Country;
countries.push(country);
allCountries[consumption.Country] = true;
}
}, {});
return countries;
}
However with growth of your Consumption table it can give you significant performance overhead. In this case I would rather look into direction of Cloud SQL and Calculated SQL model.
Note:
I gave a pretty broad answer that also covers similar situations when number of field options can be unlimited (opposed to limited countries number).
Related
I have two models, Country and City and a one-to-many relationship between them. One country can have many cities and a city can only have one country. App Maker generates a Country_fk field in the City model.
Now when I create a Create form and drop a form bound to the City model and include the related Country field App Maker creates a dropdown with the following:
options: #datasources.Country.items
value: #datasource.item.Country
Which, if I compare it with some example apps looks absolutely fine. However, I only get the Id of the related Country field not the country name field.
This has happened so many times with different models. I did once manage to create a relationship that worked, and it used the same datasource options and value values, but I can't for the life of me see why something so simple as this is so hard to do. it is so basic newbie stuff I'm beginning to give up on App maker.
You can use a little bit of help from the official documentation.
When you create a model, you can select the default display field. App Maker uses the default display field when it refers to a record in the model. A display field is commonly used for widgets that select a record, such as dropdowns.
Go to your model and make sure you select the proper display field. Something similar like in the image below.
You need to make the required field the 'Display Name' in the relevant model. Once you do this it will display as you want ๐
I have a model "address", and one field is country, in the create/edit form I use dropdown to let user select from country list, country list is store in another model called "listCountry", there are 249 countries in total, but in the dropdown options, only first 100 countries shown.
My questions and concern are:
In the options setting, I use #datasources.listCountry.items..Country, and I know there is a default pagesize of 100, but I tried to change that property pageSize as suggested by google's doc, I added to Event Load of that dropdown app.datasources.listCountry.query.pageSize = 300;, but it doesn't work, any suggestion?
I tried Search Box instead of dropdown as workaround, it works, but it requires to set a relation between Address model and listCountry model, which is not required when I use Dropdown. I'm wondering which is the best practice to store an option list, like in this case when we need give an list options such as country for an address form, is that relation setting necessary?
Thanks in advance.
In a simple scenario there is a webpage with a datagrid containing 2 columns; first name and country. There's a filter set on the grid to filter out all Australians. There's a form on the same page to add new records and a user decides to add someone from Australia. This record does not meet the filter criteria so would not normally display. However, this might be confusing from the users perspective as they might not have confidence that the person has been successfully added or have forgotten that the filter will mean the new entry is not displayed.
What is the best way to handle this from a usability perspective?:
display the new entry but leave the list in a state inconsistent
with the filter criteria?
filter out the new entry but risk confusing the user?
provide feedback to the user that the record was successfully
added but may be filtered out of the list?
?
Three tools I use, Mingle, Jira, and Quicken, use this implementation very effectively; a slight modification to your number 3:
Provide feedback to the user that the record was successfully added, but won't be shown, and provide a link to the record using its record identifier (record number + title).
I have an xPage which I have built with 3 combo boxes and 1 view control. I would like to use the 'Filter by column value' option within the view control to provide the options to filter the values, allowing the user to display any combination of the combo boxes. e.g. Only comboBox1, or comboBox1 and comboBox2, or comboBox3 only, or comboBox1 and comboBox2 and comboBox3.
I used the example in the 'xPages Demonstration Application' (http://www-10.lotus.com/ldd/ddwiki.nsf/dx/xpagesdemoapp.htm or http://xpagesblog.com/XPagesHome.nsf/Entry.xsp?documentId=AAC8E26599256FDC852578CB0066CC13) to do the multi-column filtering using a vector of non-categorized columns.
So, I have come across what appears to be a fairly major issue whereby the data needs to be sorted by date. Date is not one of the filters, but it needs to be the first column in order for the data to be sorted correctly. So my first column is a string, YYYYMMDD, to ensure the data is sorted correctly. I tried to use the sort option within the view control and that does not appear to work with the column filtering implemented in this manner.
So, as Date one of the criteria I am filtering by, I have passed that as an empty string - using the thought process that an empty string will select all (as in the url examples above).
The code I have used to do the filtering is:
var vtr:java.util.Vector = new java.util.Vector();
var t1 = sessionScope.Email;
var t2 = sessionScope.Own;
var t3 = sessionScope.Module;
vtr.addElement("");
#If(sessionScope.Own=="My calls",vtr.addElement(t1),vtr.addElement(""));
#If(sessionScope.Own=="My calls",vtr.addElement(""),vtr.addElement(t2));
#If(sessionScope.Status=="Open",vtr.addElement("Open"),vtr.addElement(""));
#If(sessionScope.Module=="All",vtr.addElement(""),vtr.addElement(t3));
return vtr;
What I have found is that not all data is being returned. I thought this might be due to the date field. So I removed it (changing the view and removing the first add element), and yet I still find that not all data is being returned. I suspect that this might be due to the empty strings being passed, or, that this does not actually work the way I had hoped.
Does anyone know if I can get this working the way I want it to, and if not, do you have any suggestion on how I can go about this?
Date is not needed as the first sortable column in the view. The first column does need to be sorted for the lookup to work just like the Notes view needs to be sorted for #DbColumn and #DbLookup to work. XPages uses the same underlining architecture. This example - http://dev.openntf.org/demos/demoapp.nsf/viewFilteringVector.xsp - works without the data being sorted by Date.
My guess as to why your example isn't working is down to how your Notes view sorted. Try creating a new view with column 1 (email) ascending sort, column 2 (own) ascending sort, and column 3 (module) again ascending sort. You should be able to get vector filtering working in this situation.
If all that doesn't work for you, you might consider multi-layer category filtering (new to 853). This filtering type in XPages is related to how categoryFilter works but allow you to filter a view by the sub-category (or sub-categories) too. This technique might suit your scenario better. Hope this helps.
I have a list of objects in an asp.net page. Each object represents a product of a shop, consisting of the name of the product, product id, price, available quantity etc. A customer can select a product from a drop down list, and the corresponding fields, such as price, quantity etc are automatically filled with the appropriate values. For performance reason, when the page loads I have fetched the whole list of products from the database and stored it inside the "Cache['Product']" variable, so that when the value change event of the drop down occurs, I can get the corresponding values without any database queries.
This strategy works fine in my local development environment, but when the page is uploaded to the server, the corresponding fields are not getting appropriate values. Even when a product is selected from the drop down, the corresponding fields are not showing the appropriate price, quantity etc. Seems like my caching strategy is not working.
I don't know what is wrong here. I have set the cache variable as follows :
if(Cache["ProductList"] == null)
Cache.Insert("ProductList", Product, null, DateTime.Now.AddHours(1), Cache.NoSlidingExpiration);
When I need to retrieve the cache values, I have done it like below :
List<Product> CachedProduct = (List<Product> )Cache["ProductList"];
I have absolutely no idea what could be the problem here. I need some help :(
If you experience different behavior locally than on a server, this may have something to do with the configuration of the server. If you have access to that, check whether there are some differences. Otherwise you might want to post a more detailed sample of your code ;)