How to change the limit on the number of list templates in the AAOS car-app - androidx

When I run the code below, the maximum number of lists is limited to 6, is there any way to change this?
listLimit = getCarContext().getCarService(ConstraintManager.class).getContentLimit(
ConstraintManager.CONTENT_LIMIT_TYPE_LIST);
As in the sample code below, if 6 or more items are added and executed, 7th list is not visible. The sample code shows the 7th list in a new screen by adding a more button. Is there a way to show more than 6 lists on one screen?
public Template onGetTemplate() {
ItemList.Builder listBuilder = new ItemList.Builder();
Row[] screenArray = new Row[]{
createRow(getCarContext().getString(R.string.pane_template_demo_title),
new PaneTemplateDemoScreen(getCarContext())),
createRow(getCarContext().getString(R.string.list_template_demo_title),
new ListTemplateDemoScreen(getCarContext())),
createRow(getCarContext().getString(R.string.place_list_template_demo_title),
new PlaceListTemplateBrowseDemoScreen(getCarContext())),
createRow(getCarContext().getString(R.string.search_template_demo_title),
new SearchTemplateDemoScreen(getCarContext())),
createRow(getCarContext().getString(R.string.msg_template_demo_title),
new MessageTemplateDemoScreen(getCarContext())),
createRow(getCarContext().getString(R.string.grid_template_demo_title),
new GridTemplateDemoScreen(getCarContext())),
createRow(getCarContext().getString(R.string.long_msg_template_demo_title),
new LongMessageTemplateDemoScreen(getCarContext()))
};
...
int currentItemStartIndex = mPage * mItemLimit;
int currentItemEndIndex = Math.min(currentItemStartIndex + mItemLimit,
screenArray.length);
for (int i = currentItemStartIndex; i < currentItemEndIndex; i++) {
listBuilder.addItem(screenArray[i]);

There's no way for you as a developer to be able to change the number of list items that can be shown as these numbers have been chosen to meet safety regulations and can vary by region. Using the ConstraintManager as you're doing is the best practice since it will automatically give you the appropriate limit (vs. hard-coding this limit).
Since the number of items may vary (with 6 as the minimum), it's recommended to include the most relevant/important items first for dynamic lists.

Related

Inserting listview items individually into database as new entries

Tl:dr
I have a listview with items. I want each individual item inserted into my sqlite database as a new entry. Right now, I am only able to insert all items into the database as a single entry.
I am able to populate the list from my database correctly. If I manually input the items in the SqliteStudio. The added items will show up as an individual item.
Code settings up the list
private ObservableList listchosedescription;
listchosedescription = FXCollections.observableArrayList();
this.descriptionschosen.setItems(listchosedescription);
Code for populating the list
while (result.next()) {
listchosedescription.add(result.getString("description"));
}
descriptionschosen.setItems(listchosedescription);
Faulty code for adding listview items to the database
Connection conn = dbConnection.getConnection();
PreparedStatement statement2 = conn.prepareStatement(sqlDesInsert);
statement2.setString(1, String.valueOf(descriptionschosen.getItems()));
statement2.setInt(2, Integer.parseInt(labelidnew.getText()));
statement2.execute();
From looking online. I think that I need a for-loop counting the individual items in the list.
for(int i = listchosedescription.size(); i != 0; i--){
Then I need to add each individual entry to a batch and then execute the batch.
I also understand how to get a single item from the listview. So I feel a little stuck, hence I thought I would post for guidance.
for (int i = listchosedescription.size(); i != 0; i--) {
statement2.setString(1, String.valueOf(listchosedescription.subList(i - 1, i)));
statement2.setInt(2, Integer.parseInt(labelidnew.getText()));
statement2.addBatch();
}
statement2.executeBatch();
In this for-loop, I have three statements:
I create an integer (i) which counts the size() of my observableList.
I run the loop as long as the size() is not equal to 0 (should probably be as long as it is larger than zero).
I decrease my integer (i) by 1 each time the loop is run.
Inside the loop, I add my two statements as I normally would. But the values from the observableList are accessed by using its subList. I acess the location using my integer (i).
i-1 will make sure I reach the correct fromIndex.
i will make sure I reach the correct toIndex.
Lastly, I add to the batch inside the loop and execute the batch after the loop.

Crossfilter total by group

Im trying to show the total number of people in each geography when they hover over using crossfilter, but my current code is only showing the total of all geographies. So what is the equivalent in crossfilter to the sql query: SELECT COUNT(*) GROUP BY dma
This is my code so far
//geography that is being hovered over, getting dma name and removing everything that is after the comma
sel_geog = layer.feature.properties.dma_1;
sel_geog = sel_geog.split(",")[0];
console.log(sel_geog);
//crossfilter to get total number of people of each geography
var dmaDim = voter_data.dimension(function(d) {return d.dma == sel_geog}),
dma_grp = dmaDim.groupAll().reduceCount().value();
console.log(dma_grp);
Crossfilter isn't meant to be used in a way where you are building new dimensions and groups for each user interaction. It's meant to build dimensions and groups before interactions take place and then update them quickly when filtering based on user interactions.
It's not really clear from this question what your data looks like or what you are trying to do, but you probably want to create dimensions and group for your dma property and then build your map based on that:
var voter_data = crossfilter(my_data);
var dmaDim = voter_data.dimension(function(d) { return d.dma; });
var dmaGroup = dmaDim.group();
At this point dmaGroup.all() will be an array of objects that looks like { key: 'dmaKey', value: 10 } where 10 is the count of all records where d.dma === 'dmaKey'. There are lots of ways you can aggregate differently with Crossfilter, but that may get you started.

AX 2009: Adjusting User Group Length

We're looking into refining our User Groups in Dynamics AX 2009 into more precise and fine-tuned groupings due to the wide range of variability between specific people within the same department. With this plan, it wouldn't be uncommon for majority of our users to fall user 5+ user groups.
Part of this would involve us expanding the default length of the User Group ID from 10 to 40 (as per Best Practice for naming conventions) since 10 characters don't give us enough room to adequately name each group as we would like (again, based on Best Practice Naming Conventions).
We have found that the main information seems to be obtained from the UserGroupInfo table, but that table isn't present under the Data Dictionary (it's under the System Documentation, so unavailable to be changed that way by my understanding). We've also found the UserGroupName EDT, but that is already set at 40 characters. The form itself doesn't seem to restricting the length of the field either. We've discussed changing the field on the SQL directly, but again my understanding is that if we do a full synchronization it would overwrite this change.
Where can we go to change this particular setting, or is it possible to change?
The size of the user group id is defined as as system extended data type (here \System Documentation\Types\userGroupId) and you cannot change any of the properties including the size 10 length.
You should live with that, don't try to fake the system using direct SQL changes. Even if you did that, AX would still believe that length is 10.
You could change the SysUserInfo form to show the group name only. The groupId might as well be assigned by a number sequence in your context.
I wrote a job to change the string size via X++ and it works for EDTs, but it can't seem to find the "userGroupId". From the general feel of AX I get, I'd be willing to guess that they just have it in a different location, but maybe not. I wonder if this could be tweaked to work:
static void Job9(Args _args)
{
#AOT
TreeNode treeNode;
Struct propertiesExt;
Map mapNewPropertyValues;
void setTreeNodePropertyExt(
Struct _propertiesExt,
Map _newProperties
)
{
Counter propertiesCount;
Array propertyInfoArray;
Struct propertyInfo;
str propertyValue;
int i;
;
_newProperties.insert('IsDefault', '0');
propertiesCount = _propertiesExt.value('Entries');
propertyInfoArray = _propertiesExt.value('PropertyInfo');
for (i = 1; i <= propertiesCount; i++)
{
propertyInfo = propertyInfoArray.value(i);
if (_newProperties.exists(propertyInfo.value('Name')))
{
propertyValue = _newProperties.lookup(propertyInfo.value('Name'));
propertyInfo.value('Value', propertyValue);
}
}
}
;
treeNode = TreeNode::findNode(#ExtendedDataTypesPath);
// This doesn't seem to be able to find the system type
//treeNode = treeNode.AOTfindChild('userGroupId');
treeNode = treeNode.AOTfindChild('AccountCategory');
propertiesExt = treeNode.AOTgetPropertiesExt();
mapNewPropertyValues = new Map(Types::String, Types::String);
mapNewPropertyValues.insert('StringSize', '30');
setTreeNodePropertyExt(propertiesExt, mapNewPropertyValues);
treeNode.AOTsetPropertiesExt(propertiesExt);
treeNode.AOTsave();
info("Done");
}

Sizing a spark list

I'm using spark Lists and PopupAnchors to build a drop down menu system, but I'm having trouble getting it to size reliably - the list always seems to want to take up 5 itemRenderers worth of space, but some of the menus I need to implement can be 3 or less items long. How can I have the list dynamically size to the number of elements in it, and no larger?
This is a fun one. You need to set the property on the VerticalLayout of the spark list.
Try this snippet:
(yourSparkList.layout as VerticalLayout).requestedRowCount = yourDataProvider.length;
This assumes you've got a list named yourSparkList and a dataprovider called yourDataProvider which is populating the list.
If your lists get long, you should set a MAXIMUM constant like so:
public static const MAXIMUM:int = 5;
if(yourDataProvider.length <= MAXIMUM){
(yourSparkList.layout as VerticalLayout).requestedRowCount = yourDataProvider.length;
}else{
(yourSparkList.layout as VerticalLayout).requestedRowCount = MAXIMUM;
}
BTW, there's also a requestedMaxRowCount and a requestedMinRowCount property.

Flex - sorting a datagrid column by the row's label

I'm creating a table that displays information from a MySQL database, I'm using foreignkeys all over the place to cross-reference data.
Basically I have a datagrid with a column named 'system.' The system is an int that represents the id of an object in another table. I've used lableFunction to cross-reference the two and rename the column. But now sorting doesn't work, I understand that you have to create a custom sorting function. I have tried cross-referencing the two tables again, but that takes ~30sec to sort 1200 rows. Now I'm just clueless as to what I should try next.
Is there any way to access the columns field label inside the sort function?
public function order(a:Object,b:Object):int
{
var v1:String = a.sys;
var v2:String = b.sys;
if ( v1 < v2 ){
trace(-1);
return -1;
}else if ( v1 > v2 ){
trace(1);
return 1;
}else {
trace(0);
return 0;
}
}
One way to handle this is to go through the objects you received and add the label as a property on each of them based on the cross-referenced id. Then you can specify your label property to display in your data grid column instead of using a label function. That way you would get sorting as you'd expect rather than having to create your own sort function.
The way that DataGrids, and other list based classes work is by using itemRenderers. Renderers are only created for the data that is shown on screen. In most cases there is a lot more data in your dataProvider than what is seen on screen.
Trying to sort your data based on something displayed by the dataGrid will most likely not give you the results you want.
But, there is no reason you can't call the same label function on your data objects in the sortFunction.
One way is to use the itemToLabel function of the dataGrid:
var v1:String = dataGrid.itemToLabel(a);
var v2:String = dataGrid.itemToLabel(b);
A second way is to just call the labelFunction explicitly:
var v1:String = labelFunction(a);
var v2:String = = labelFunction(b);
In my experience I have found sorting to be extremely quick, however you're recordset is slightly larger than what I usually load in memory at a single time.

Resources