how get item from each cell in grid - grid

I have form with grid. I defined dataStore with 2 columns (text and checkBox). Grid.store = defined dataStore. Second column is editable (you can change selection on each checkBox). I have some button, and when I click it, I want to get info about each cell. Example if have gird:
Name1 true
Name2 false
I want get info col[0].row[0] is equal 'Name1', col[0].row[1] is equal 'Name2'.
I try iterate on dataStore but it has only value which I put them by hand. The value which was changed on grid by clicking on checkBox didn't save in dataStore.. My question is how to iterate on grid, how get info about each cell.

To iterate across a store in Ext3, you can use dataStore.each()
Supply it an anonymous function and the parameter it receives will be the current record in the store. The data in the current record can be read by using record_var.get(field_name).
So, for example:
var dataStore = myGrid.getStore();
dataStore.each(function(rec){
alert(rec.get(field1));
}

Related

Progress-4GL: How to dynamically add a fill-in in a form and take user input in it?

I've a form in a base QAD mfg/pro (ver 10.2) program. I know the names of form, frame and fields. I'dont have access to base program's code modification. I've a wrapper program that access various fields from the existing form using handles, first-child, next-sibling etc.
What I want to do is to add a fill-in into this form/frame from the wrapper program and during runtime, take user input into that field.
I've been able to create text (for label) and fill-in field (called user) in the frame, however, the field is in't enabled.
create fill-in txt_user
assign
name = "txt_user"
row = 7
column = 19
frame = hWidget
visible = true
side-label-handle = lbl_user.
How can I enable the fill-in field txt_user and take input in it?
To Enable the field set the SENSITIVE property to TRUE. To query the current value, read the INPUT-VALUE property.

Access value from a list row from a script in App Maker

In my main data input in my Google App Maker app, I have relation data that's displayed in a list. I want the entries in that list to be able to be null until the user takes a specific action by clicking on a particular button, but at that point, I want the existence of values to be validated.
For the life of me, I couldn't figure out how to access iterate through the rows in the list and check the value of a specific field. But after a TON of trial and error, I figured it out -- see below.
Starting with the list widget (MyList), get the rows contained in it:
var rows = MyList.children._values;
To access the widgets in an individual row, identify them as an array first:
var widgets = rows[0].children._values;
Then get the value of the widget you want by identifying by index:
var value = widgets[0].value;

Return value of another field within model

I have a model with two fields, Name and Token. In my app, the user will select a record from a Dropdown populated with the Name field of all records. When this happens, I need to assign the record's corresponding Token value to a variable in a server script, but am not sure how to accomplish this.
There are two options that are suitable. As a first option you could implement a server script that returns the token of the field when you edit the widget.
function checkToken(widgetValue) {
var query = app.models.YourModel.newQuery();
query.filters.Field._equals = widgetValue;
var records = query.run();
return records[0].Token;
}
You can add the script caller checkToken(widget.value) to the onValueEdit event of widget, so that it runs every time you select another dropdown item. If you want to use another event, please look at https://developers.google.com/appmaker/ui/logic#events.
As a second option you could add a secondary label to your form which you bind to the dropdown item selection. The binding would look something like this:
#pages.MyPage.descendants.DropDown.value.Token
When you configure Dropdown you need to set three important properties:
options
An array of string representations of options that makes up the content of the dropdown
#datasources.MyDatasource.items..Token
names
An array of strings to be displayed in place of options' default strings. The array must be the same length as options.
#datasources.MyDatasource.items..Name
value
The value assigned to the databound property, based on the user's dropdown selection
// Assuming that dropdown is added to form
// or any other container bound to proper datasource.
#datasource.item.Token
Note
double dot .. syntax is used for projections

Expand/Collapse GridView rows of the same type

I have a gridview with some boundfields and templatefields. My data are sales Unit-Price-Store, right now the user selects a store (from a DropDownList) and the Grid is all Unit-Price for that store.
Is there a way to make put a button next to each unit so that when the user clicks it, that row expands to include a new row for each store? IE, when I'm looking at Store 1 and I click the button I also get to see Unit-Price info for Stores 2,3,4 (but just for this item)?
I used jQuery. Basically, I tagged that column and then did an each statement. If value.innerHTML != Store $(this).closest('tr').hide(); Else assign it a function on click that looks at all 'tr' where Unit matches but Store doesn't and slideToggle()

Flex DataGridColumn with array of objects as data provider

I have a datagrid that uses an array of objects as the data provider. The objects are essentially key/value pairs:
{ foo:"something"}
{ bar:"hello"}
{ caca:"lorem"}
The datagrid has 2 columns. The first column is the key and the second column is the value. Right now my grid looks like:
My dataFormatter function makes sure that depending on the column (i.e. the dataField value) the correct key or value gets printed out. This works fine for displaying. However, as soon as I try and edit the value field it essentially adds a new value into the object with a key of '1'. For example, if I edit the {caca:"lorem"} object it will then contain the value {caca:"lorem",1:"new value"}.
Is there any possible way I can set the DataGridColumn so that when I edit a value it will update the value associated with the key rather than inserting a new value? I've tried using a custom item editor but it still does the insert. It seems like I need to be able to update the 'dataField' with the actual key value but I'm not sure how to do that.
Looks like you need to think about where your data is going to be stored. I would recommend listening for a CollectionEvent.COLLECTION_CHANGE event on your data model. That event object will contain info about what change occurred, and you can make any updates you need to make.

Resources