Ag-grid dynamically span entire row - datagrid

I have a grid that presents database entities one per row with some crud options (the crud options are icons in their own cells). When the delete button is clicked, the design calls for the entire row to be turned into a confirmation message with buttons to continue or cancel.
Apparently you can give a function for colSpan on each colDef. I tried giving the first colDef a span equal to the number of displayed columns in the case that the row data has a property isDeleting === true, while clicking the delete icon would set the row data's isDeleting property to true.
I was unable to get this to work, and even if I were to get it to work, I'd need to be able to dynamically change the cell so that it contains the confirmation message.
Any help is greatly appreciated.

After a very long day of searching, I found this article on "full-width" rows. You can provide your gridOptions with an isFullWidthCell function, plus fullWidthCellRenderer and fullWidthCellRendererParams properties, and the full width of the row will be populated using the renderer according to the params (as is the case with a cellRenderer in a ColDef)
So, my delete button component can set a piece of data that the isFullWidthCell function can check for, and if it finds it, it will use the cellRenderer provided.
AgGrid seems to have thought of everything.

Related

WKSwipeGestureRecognizer not working in cell of WKInterfaceTable

I'd like to get swipes on certain cells within a WKInterfaceTable.
It is possible to add a WKSwipeGestureRecognizer to a group within a cell but the action is never called.
Adding the recognizer to the table works but this way I cannot get a reference to the cell that was tapped.
Any ideas/ or solutions to this issue?

How to figure out the index of a ToggleGroup's selected toggle?

I'm trying to select an item from a list that's sorted the same way as a ToggleGroup I have besides it. However, I found that toggleGroup.getToggles().indexOf(toggleGroup.getSelectedToggle()) always returns -1 (visible in the IndexOutOfBoundsException thrown as I pass it). Is there another way of figuring out the index, or am I at a loss with my approach and need to figure out something completely different?
UPDATE: Apparently, for the first time an item is selected (I have this code attached to changes of selectedToggleProperty()), it works fine (I just get no notice of it because the elements I make visible have no proper layout). However, when an item is selected while another item already is selected, getselectedToggle() becomes null, causing aforementioned behavior.
All of the JavaFX toggle controls have a property called UserData. You should use that to create the links between the toggles and data list. Relying on the index of the toggles in the toggle group is probably a bad idea.

Remove Style from table in Code Behind

This should be a lot easier than it appears to be, but I'm having an issue with it.
Conditions
If upon entering this specific page, if there is only one record in the grid (based on a status value in a dropdown), hide the grid and show a table with the details of that record.
If there is more than one record, display the grid with the records.
When a record is selected, display the table with the details of that record.
When I go into the page currently, there is only one record, so it is displaying the table. If I change the value of the dropdown to another status, more than one record is in the grid and the table is hidden. Previously (by another programmer) it was being set to Visible = false. Obviously, this is not a property of the table. However, it previously worked as when someone would select a row, they would set the Visible = true and the table would show.
I've now changed it to hide by using:
tblDetails.Attributes("style") = "display:none"
However, trying to replace the Visible = true is not working:
tblDetails.Attributes.Remove("style")
I have also tried:
tblDetails.Attributes("style") = ""
Someone please point out to me the solution that is going to make me slap my forehead. Thanks.
use setAttribute(attr,value) to change the value of each Element You want
like below example
yourelement.setAttribute("style","");//it is to change value
yourelement.removeAttribute("style")//it is used to remove style attrb from your element

What is the proper way to create subtable in a QTableWidget?

I have already implemented a subtable functionality in a QTableWidget. That is, if you click a row that contain a Left Arrow icon, a new row will be added and in there another instance of QTableWidget will be attached using setCellWidget.
All is working fine.. until I need to sort the table in an interval bases: this row that contain subtable, should be kinda sticky to its parent row. But, the sort method made them separate. I browse again the documentation, and I found this : QAbstractItemView#setIndexWidget. I am not sure how to implement this, but it seems like it will make the subtable attached to this row, without the need to add a new row.
Have you face this kind of issue before? Would love to know how you solve it
UPDATE
I think the proper way is indeed to use QAbstractItemView.setIndexWidget: it'll keep the data / model untouched so the rows can be properly sorted. We just have to properly display a new widget that don't override the current data appearance

Flex DataGrid prevent a filter from being applied automatically

To situate things I am working on a translation utility with a datagrid having 3 columns : translation code, reference text and target text.
The DataGrid's dataProvider property is bound to an ArrayCollection instance. The user can edit the grid and on a successful edit, the underlying collection is updated using the setItemAt() method. The collection also has a filter function to make it easier to find certain texts.
When the user clicks the 'apply filter' button the filter function is updated. This works well. The problem I have is that rows are hidden as soon as the underlying collection item change in a way that doesn't comply with the filter. The row is hidden immediately, which is not very user friendly. Rows should only hide (or be shown) when the 'apply filter' button is pressed.
I'm searching for a way to make this happen.
I assume you mean that the DataGrid's dataProvider is bound to an ArrayCollection instance?
Anyway, if you want to filter the DataGrid's dataProvider then that will remove rows from the DataGrid. You can remove the filter to add them back in. Something, conceptually like this:
collection.filterFunction = null;
collection.refresh();
If you are using the dataProvider as a source for multiple components, you can keep the filtering separate by using a different ListCollectionView for each one, but with the same source. Something like this:
component1.dataProvider = ListCollectionView(mySource);
component1.dataProvider = ListCollectionView(mySource);
Now applying a filter to one dataProvider will not affect the other.
If this doesn't help, you'll need to expand on the issue you're having and perhaps provide sample code.
After asking and looking around, I determine that there is no real way to do this. I did solve my problem however, by doing the filtering myself and only keeping a list of 'primary keys'. I then use that list to filter the collection.
The result is that rows can't suddenly disappear when records are changed, which is what I wanted.

Resources