add a row to a datagrid where a user can input data in as3 - actionscript-3

what i am trying to achieve is to have data populate a datagrid from a query, this part works fine. but once the data has been populated i want to add an additional row which the user will be able to type into. so for example the grid will have 5 pre populated rows and then the 6th row will be empty cells which the user can edit. the final column of this row will either be a button or an image with the click property set. this will be used to run an update query to update the dataprovider of the datagrid.

This is pretty easy. Just add a new object in your List that is bound to the datagrid. For the final column you will need an item renderer.
Ex:
dataGrid.dataProvider = someList;
//later when it is populated
someList.addItem(new Item());
After this you can set the focus to the desired column and the last row to show its input time.
You can also remove the last added item from the list to simulate a cancel action.

You will also need to set the 'editable' property of the grid to true. Set the selectionMode property to 'singleRow' Each column also has an individual 'editable' property so you can limit users to only changing certain properties.
As long as the data is simple text the default item editor (which is a textInput) will work fine. If you use an advancedDataGrid you can also include things like checkBoxes for Boolean data.

Related

Dynamically changing the bound entity of a list box on a canvas

I'm wondering if anyone has come across this issue.
I have two radio buttons on a canvas app that I am attempting to control the values displayed within a list box.
RadioButtons.Items: ["SomeValueA","SomeValueB"]
The list box control should be getting reset whenever the value of the radio button changes.
UpdateContext({resetList: !resetList});
UpdateContext({resetList: !resetList});
Reset(lbListbox);
lbListbox.Reset: resetList
For the list box itself I have the following for Items:
Switch(
RadioButtons.Selected.Value,
"SomeValueA",
Sort(
EntityA.FieldName,
Descending
),
"SomeValueB",
Sort(
EntityB.'Some other field name',
Descending
)
)
The problem is when I select 'SomeValueA' the list box properly populates with the values from EntityA.FieldName but when I then select 'SomeValueB' from the radio buttons the list box blanks out with empty records. There appears to be items in the list box that I can scroll through and select but not see.
If I put two list boxes on the screen and set their Items event to the specific entity the values show up properly in both list boxes so I know the entity naming/field is correct.
I've tried it without the reset of the list box, I've tried it using collections made out of the entity records.
Has anyone come across this who maybe has a solution. I was going to try to put two list boxes on top of one another and either hide/show or bring to front the active list but that also doesn't want to work.
thanks!
(Received this post from another source, figured I might as well post back here as well)
Got this to work, but it was a bit finicky. The catch seemed to be giving the List a value-pairing table, instead of just a list of values.
First I collected the Option Sets from CDS, and added a column to indicate the source name, for reference. This could easily be combined into a single collection, and then filtered later but I was thinking simple.
ClearCollect(colOptionSet1,AddColumns(Choices('Ownership (Accounts)'),"appSource","Ownership"));
ClearCollect(colOptionSet2,AddColumns(Choices('Preferred Method of Contact (Accounts)'),"appSource","Preferred Method"));
Next added a Radio button identical to yours.
Then added a List control with Items equal to
If( Radio1.Selected.Value = "SomeValueA", colOptionSet1, Radio1.Selected.Value = "SomeValueB", colOptionSet2 )
You may need to use the right-side property pane to toggle between Value and "appSource" (from collections above), but this did allow me to toggle between two separate Option Set fields in a single list.
Patching/writing this back is gonna be another hurdle. 😝

How to add a custom component in Datagrid on first empty row?

I am loading some data from a database table in a datagrid in Flex and I require a custome component on the first empty row or on empty rows, so user can add data in to that row. How can I do that? I do not want to make the datagrid column editable.

how to make the last row of an as3 advanced datagrid editable while all other rows are not editable

I'm trying to make a single row of a data grid editable. so if I have 5 rows of complete data these will remain uneditable. however I will have added an additional empty row and this is the only row I want the user to have access to edit. this is being done using as3 in and advanced data grid.
using the editable property of the data grid I have made the entire grid editable but this will be an unacceptable outcome
Specify editable property of datagrid as true but specify all the colums of datagrid editable property false
On ItemClick event check the rowindex.
If rowindex == 5(where u want ur datagrid to be edited) use editable property of datagrid for all colums to true else false
Hope you got it!!!
Source: https://forums.adobe.com/thread/665669

AdvancedDataGrid: row moves to the bottom of the ADG when editing a value

I have an AdvancedDataGrid with editable set true on some columns. If i edit one of the values in the ADG, the row moves to the bottom of the node/branch containing the items im currently editing.
My AdvancedDataGrid is defined in ActionScript3, and i use a grouping collection to group a flat dataProvider.
My problem is that i often want to edit several cells of one row, and if i edit one of the cells and then click somewhere else, the row moves to the bottom of the ADG. How can i avoid this? I want the row to stay selected and at the same index.
I guess i was a bit to quick to post this question, but maybe my mistake helps someone else. At the time of creating the editing, i didnt know about the itemUpdate(object) method of the ArrayCollection, so i removed the item, updated the item and then added it to the same index again(code below):
ac.removeItemAt(i);
ac.addItemAt(event.itemRenderer.data, i);
This does not work together with the hierarchical data in the AdvancedDataGrid. Insead of beeing inserted back in the right index it is displayed at the bottom of the current branch in the ADG. The solution was very simple by using the following code, which works with the GroupingCollection:
var field:String = event.dataField;
var obj:Object = event.itemRenderer.data;
//Update the field that was edited by the user
obj[field] = editedValue;
//update the object in the dataProvider
ressursTavle.itemUpdated(obj);

Access 2007 - Display text fields in drop down list while bundling to an ID

in Access 2007 how can I display text fields in drop down list while bundling to an ID? not while selecting (we can do this by plying with the width field. but what I need after selecting?
Do we create a hidden field that stores the ID?
Your description of how a combo box works is correct. Keep in mind that while you're setting the first column and display length to zero, that means the combo box will then search by the second text column. The combo box will display by that second text column after you select a value. In fact in all cases for typing in a value, even partial matching as you type, a simple select of a value will ALL BE done by the displayed text column but in ALL CASES it will save the actual ID (the first column) into the table that the form is bound to.
So no additional coding or anything if need be done on your part to achieve the above goal and in fact this is pretty much the default as to how combo boxes work inside of ms access.
What makes the combo box is somewhat unique inside of Access is you can have more then 2 columns. And, in the combo box settins you can choose what column is to be selected and saved into the table. And, the combo box has both before update (with a cancel), and after update and also a Not in List event that fires in the case of a user tyring to type in a value that not in the list.
So, the Access combo box is quite flexible. The source for the list or members displayed in the combo box can be based on a table, on a query, or you can even type in a value list that is saved inside of the property sheet. And, another option is to fill the combo box is by using call backs (so, again quite a few ways to fill out the list of memebers for selectiogn).
So, keep in mind there is two aspects to the combo box. There's a so called row data source or how you feed the members that will display in the combo box. Then there is the underlying column (field) that you bind that control to when you select a value. That is in the case when the combo box is bound.
As mentioned, the bound column setting is another property in terms of inside the combo box, and you don't need to write any additional code to achieve that above goal in your question.
Albert Thank you for this excellent explanation.
I found out that the bound column has no effect. Acces take the first visible field and bound to it regardless of what you have in the bound column property.
All good thanks
Omar ( hostitwise.com)