I have an editable DataGrid in Flex, with data full of numbers. The columns have no special itemRenderer, but a labelFunction, which returns the number as-is if positive, but puts it in parentheses if it is negative, like so
27.3 => "27.3"
-27.3 => "(27.3)"
Now, these cells are editable. When I try to edit a cell with a positive number, nothing is wrong. But if I try to edit a negative number, it starts editing (27.3) instead of editing -27.3. Because of this, when the edit is done, the labelFunction is evaluated with the new value in parentheses(i.e., labelFunction is called with "(30.5)"), and converting it to a Number results in NaN.
So, I want to know if I can make the DataGrid edit the data in the dataProvider instead of the label that it shows.
I hope I am clear with the condition. Please ask if you need any clarification.
Thank you.
Is this what you're after?
Example: Modifying data passed to or received from an item editor - From livedocs.adobe.com
(You may still have to scroll down once the page loads... The anchor doesn't seem to be working for me.)
Related
I'm in need of a little help in here . I'm getting results that come from virtual property , but one row displays in multiple rows in view. How to display a record inside a row , and not in multiple records
#foreach (var item in Model.Event.Id)
appears to be your problem. You're looping over the event ID, which since it's a string, will be treated like an array of characters. Therefore it prints one character from the ID on each line, and then, because of the rest of the code, repeats all the other details of that event on each line.
Since you only appear to have one single Event in your Model, it seems that you do not need any kind of loop here at all.
However it's not entirely clear what your intentions are - perhaps you intended to loop over something else in your model which is not shown. If so, please clarify the question and possibly the answer could be expanded.
I am trying to use doStartEdit(inCell, inRowIndex) function of datagrid to open first cell of newly added row for editing in dojo 1.9 Enhanced grid, but the function does not work.
It says in api that the arguments should be:
inCell - object of a cell (I get it with getCell() function)
inRowIndex - index number of a row
I am not sure because arguments are not clearly described in the api, I tried to look at the same variable descriptions near other grid functions.
I tried other variations of arguments, like cell number insted of object, and row object instead of row index. None of them worked. Is it a bug? Or I just use it in wrong way?
If you are looking to do is focus and set a cell for editing by the user then below should work for you.. that will focus on column 1 row 1.
grid.edit.setEditCell(grid.getCell(0),0)
Fiddle:http://jsfiddle.net/Pjzef/
I would like to edit a cell by the row and column indexes so essentially do the following:
advDataGrid[2][3] = "Dogs"
so that I am setting the data grid row 2 and column 3 to Dogs. I cannot for the life of me figure out how to do this!
Side note: I need this because I am trying to allow the user to copy a section of an excel file to a section of an AdvancedDataGrid like Google Docs does. I am using this idea to do it: http://mannu.livejournal.com/348299.html
Thanks! Any help will be greatly appreciated!
In general you want to operate on the dataProvider rather than the presentation (AdvancedDataGrid). So in your case, I would get the item associated with the specified row from your dataProvider and modify whichever element is specified to "Dogs". So something like this: adg.dataProvider[row].someColumnData = "Dogs"
EDIT: "someColumnData" refers to whatever property you have set for the column to display. So when you defined your AdvancedDataGrid's columns, you set the 4th column to use the "someColumnData" property of the items in your dataProvider, and you want to change the value in the 4th column, then you'd set it as described above. Hope that clarifies things.
Flex components are data driven, so you should modify the data provider of the grid.
What if you want to edit specific individual cells, eg I want to to keep running totals of some cells in other cells, IE: as a user edits I update whole columns.
Surely their must be a way to walk the array and get Column4.row6 = something.
My problem is that empty rows (if there are more rows that dataSource items then there are empty rows) look identical to rows binded to dataSource items which are empty (see the difference?).
The only way to know the difference is to hover over them with the mouse, and if they are empty there's no color change, otherwise there's the blue background of the selection..
I want to change the color or in some way hide empty rows, those that are not bound to a dataSource item.
How can I accomplish this?
You can format your DataGrid using ItemRenderer.
The itemRenderer is a display object that get the data from the data provider and display it in the grid.
Writing your own logic can help your specific data display in general. in this case, check for data on the ItemRenderer object creationComplete. it the data is null or empty - display a sign (or whatever).
See this link as reference:
http://blog.flexexamples.com/2007/08/20/formatting-a-flex-datagrid-control-using-a-custom-item-renderer/
Enjoy!
I'm not sure if this is exactly what you are looking for but I cut off my rows at the end of my dataprovider like this:
myGrid.rowCount = myDP.length();
This can of course be modified with some simple logic to have min, max, or if it's a data entry type of grid length()+1.
I have a flex datagrid. it is bound to an array collection. if the user sorts on column X it works fine. then, if the user causes the array collection to change, the datagrid forgets that it was sorted on column X.
what do I need to do to preserve this sort preference so that the new array data will appear sorted by column X?
I posted this question on another forum and got a good answer that worked well. Here it is:
If your data is in ArrayCollections you can assign a ListCollectionView to the dataProvider property of your child AdvancedDataGrid and assign your ArrayCollection data to the 'list' property of the ListCollectionView. When you want to change the data in the child grid, reassign the list property of the ListCollectionView. This way you avoid reassigning the dataProvider of the child grid directly, which is what causes the grid to reset.
here's the link to the post:
http://forums.adobe.com/message/2206736#2206736
That really helped, thanks. But don't forget to Refresh() the dataProvider once you have reset the sort:
dataGrid.dataProvider.refresh();
I have same kind of problem but didnt knw why it was happening so did some tweaking
selectedItems=dataGrid.selectedItems;
postionGrid=dataGrid.verticalScrollPosition;
sortPostionGrid=dataGrid.dataProvider.sort;
store them in a variable and when data is changed just put the again on the grid it is not a good approach but it worked for me
This post "Keeping the sort on a datagrid when you change the dataProvider" gives
more relevant and efficient solution what you looking for
Hopes that helps