How to mark record in grid without checkbox? - grid

I have two grids. The first displays keys, and the second displays a list of related items in another table. Since the grids are on different tabs, I put a filter on the pageActivated method for the second grid's tab.
Some pseudo code to get my point across without posting 200 lines of x++
override page2Activated() {
dataSource2_ds.removeFilter();
dataSource2_ds.filter using grid1Field.valueStr();
}
This works nicely, as long as grid1 has rows in it when the form is opened. If there are no rows when the form is opened, even after adding a row to grid1, something doesn't get updated, and grid2 will always be blank.
Then, I tried looking at the datasource instead of the grid fields.
override page2Activated() {
dataSource1 firstTable;
firstTable = dataSource1_ds.getFirst(true);
dataSource2_ds.removeFilter();
dataSource2_ds.filter using firstTable.recID;
}
The problem with this one is that it only works if you click the checkbox next to a record.
I'd like to to work with a highlighted record in grid1, without having to click the checkbox.
Any suggestions?

Question answered in comments above. Posted as answer so the question can be marked closed.
Rather than using code to manually filter the records, link the tables using the datasource properties JoinSource and LinkType. Set JoinSource to the linked table and LinkType to Active.

Related

Ag-grid dynamically span entire row

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.

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

Delaying the opening of a NSPopUpButton

I've encountered the same problem as this one:
This one.
It has never been answered so far. In two words:
When you place a NSPopUpButtonCell in a NSTableView, the popUp opens before the selection in the tableView has changed.
If the menu of the popUp relies on the selection of a row of the tableView, it will be updated too late.
Solution 1: differ the opening of the popUp with a block which calls [super] a few nanoseconds later. But I don't know which method I must override.
Solution 2: use other bindings that I'm currently using (the popUp contains the NSSet of the entity selected in the table, I'm using a different controller, not the table's one, and I bind its content set to myTable.selection.theSet.
Is there something else I could do? Thanks !
Yes, if you use a view-based tableView, you can bind the popUp through the cellView it’s inside (like the other table objects you bind in this mode), and so it’s completely unambiguous and doesn’t depend on the selection.
In view-based mode, each cell in each row have is assigned an ‘objectValue’ from your original data, so you can bind directly to it, like ‘objectValue.popUpContents’.

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.

jqGrid ASP .Net Permanent 'Add new row'

I've been using jqGrid ASP .Net and really happy with it but I required a permanent blank new row at the top of the grid which allows a user to enter a new row on the fly rather than using the add row dialog.
From looking at the trirand forums, this is currently not supported 'out of the box'.
I have seen this forum post http://www.trirand.net/forum/default.aspx?g=posts&t=212 but it doesn't work (alert is shown but nothing else happens) and also requires the user to click the New button rather than the new row always being at the top of the grid.
Any help would be greatly appreciated,
Cheers
Additional Information:
I am wanting a permanent blank row at the top of the grid where the user enters every new row, below this row would be the data already entered (loaded from the database on page load). As the new row is added (when the user hits enter) the row is displayed in the grid (which I gather would also fire the OnRowAdding event for me to insert into the sql server) and the permanent new row would clear its values ready for new entry. I am also using inline editing (which is working fine) and committing the changes to a sql server database. I am populating the grid on load of the page by setting the datasource to a datatable and calling DataBind()
Look at this example which I created for the answer. The example works with local inline editing and fill the grid with empty data at the beginning. You can modify it and fill only in the first line empty data and all other rows fill with "real" data.
Another way: you can just place "New" button above the rows (see Add toolbar in the bottom of the header using jqgrid which describes how to do this) on the second navigation bar. So users will see it immediately. You can also place custom button instead of a standard "New" button. This custom button (for example "+") could just insert a new row and goes in the inline editing mode.
If all this is not what you want, you should include in your question more detailed information which kind of editing you use (inline, cell or form), where you hold the data (local, only on the server or use loadones:true to have a mix data holding).
Ended up solving this problem by inserting a new row to the datatable when I populate the grid as follows:
DataRow dr = dtTimesheets.NewRow();
dtTimesheets.Rows.InsertAt(dr, 0);
grdTimesheet.DataSource = dtTimesheets;
grdTimesheet.DataBind();
Then on the RowEditing method I check if it is the in fact the new row and perform my insert instead of an edit and then reload the grid which puts a new empty row at the top of the grid again.

Resources