I have a dynamically sized DataTable in Flutter, and I would like to allow selection of DataRows via checkboxes. I understand that each datarow has a selected and onSelectChanged attribute, but I don't know how to change a property of the DataRow itself using the onSelectChanged callback. I know I could add an array of boolean values to the containing widget's state and then edit with the callback, but that seems really slow and inefficient. Any ideas?
You change the property on the data you use to render the DataTable and then render it as selected when it was selected.
Related
I need to slightly modify a ag-grid row after it has been rendered. In ag-grid, the actual HTML elements are not necessarily persistent, so manually-set styles may fall off.
For one thing, I have to modify the selection checkbox to set its tabindex to -1. This can technically be done in the cellRenderer callback, although it looks quite hacky. (The checkbox can be found at params.eGridCell.children[0].children[0].wrappedElement.)
But I also have to add a CSS class to some rows to highlight them based on external criteria. I haven't found a way to do this at all.
The best solution would seem to be using some sort of after-rendering callback, but to my knowledge no such thing exists.
I found a couple of related questions, but they were both resolved via cellStyle, which would not suffice here:
Row formatting in ag-Grid
How to provide a background color for an entire row in ag grid based on a certain value in a column?
You have not 1 but 3 options:
getRowClass(params):
Callback version of property 'rowClass'. Function should return a string or an array of strings.
getRowStyle(params):
Callback version of property 'rowStyle'. Function should return an object of CSS values.
processRowPostCreate(params):
Allows you to process rows after they are created. So do final adding of custom attributes etc.
In this last one you have the row in params.eRow.
All taken from https://www.ag-grid.com/javascript-grid-callbacks/index.php
I`m trying to add addValueChangeHandler function to a TextBox inside a flexTable.
But when I add this code:
int rowIndex = tableImages.getCellForEvent(event).getRowIndex();
I use this method to know the current row in case of a ClickEvent.
the method is not acceptable for ValueChangeEvent,
so how can I know what is the row Index for the changed cell?
Thank you.
Well yes, because it needs a Cell itself, not a TextBox or event value.
What you can do, is:
Get the event Source via event.getSource()
Cast it to Widget at least (though it's safe to assume it's a textBox) Widget sourceWidget = (Widget)event.getSource();
Get the source widget's element's parent sourceWidget.getElement().getParent();
This way you'll acquire the actual <td> cell your textBox nested in.
Then you can getCellFormatter of your table and find the index of the cell in a loop, comparing the <td> element you got with the cells of your table.
Please tell me if it solved your problem
I have a listview and a button outside listview. I want the user to select an item in listview and then when clicking on button I wanna get the selected item of list view. I have set choiceMode to single choice on listview, but when I try getselecteditem it returns null. How should I get the selected Item?
thanks.
This is an old question, so probably not that relevant anymore. But here's what's the problem:
The ListView doesn't store selected item position when you just set the choice mode. It stores the checked item position.
In short, you would use something like:
int pos = listView.getCheckedItemPosition();
myObject = (MyObject) listView.getAdapter().getItem(pos);
i have two dropdowns using same model and sets the value into it. Dropdown1 will visible on screen always and Dropdown2, will be visible for only one particular option choosen in Dropdown1. and i am making an query to the DB based on the selections in dropdowns.
But when i have both the dropdown first and then hide the second one, The value already set but the Dropdown2 is still avalible in my model, and making my query to fetch improper data.
So can any one suggest me an idea, how to set the value to null for the attribute which is actually set but dropdown2, if dropdown2 is inVisible.
(i tried to set the ModelObject to null, when making the dropdown2 invisible (using AjaxFormComponentupdateBehavior), but when i make the dropdown2, visible again, it returns null,even if i make any selection in it)
Are you using a LoadableDetachableModel ? try to explicitly detach model from that dropdown on setHide event. I did not try it though.
I have an list of checkboxes on a GWT widget using Gwittir. I want to bind these checkbox values in my view to some values in my Model so that I can tell which ones are selected. How can I set up a binding to do this?
For a single value (one not in an array), I've been doing this:
Binding binding = new Binding();
binding.getChildren().add(
new Binding(viewObj.getTextBox(),"value",modelObj,"textValue"));
But I don't know how to transition this to work for an array of items. Please help.
I ended up not using Gwittir for those parts which dealt with arrays of data. Instead I manually transferred the data from my view to my controller when the user clicked a button which would record the state of all the checkboxes in an array to an array of values in the controller.