As you know, dgrid 0.4 now uses the dstore package instead of dojo's store. Using the Rest.js in dstore, I simply want to add a new row to the dgrid using a rest call. This works fine. However, it adds the row at the end (as the last row) of the dgrid. I need to add the row at the beginning (making the newly added row the first row of the dgrid). Inside Rest.js, there is a variable called defaultNewToStart which I figured would do the trick, but even when set to true, dgrid still adds the row at the end. Any advice on how to get Rest.js in dstore to add a row to the beginning of the dgrid.
I figured out what I did wrong. In dgrid/OnDemandGrid, I set the property "sort", which was causing the queryExecutor in Trackable.js to put the newly added row at the end instead of the beginning. So all I had to do was remove the sort property, and now it works fine.
The add function of dstore/Memory supports PutDirectives as second argument other than the item you are trying to insert. PutDirectives has a property beforeId which can be used to insert the item before any existing record in store.
To add an empty row at the beginning:
var beforeID = null;
store.fetch().forEach(lang.hitch(this, function(data) { beforeId = data.id;}));
store.add({id: ''}, {beforeId: beforeID});
Related
I want to remove all content of a page and insert different content into it with a click of a button.
Unfortunately some of the content is the same and therefore has the same id.
I expected it to not be a problem because I never try to insert the same element twice. I want to remove it before reinserting it again.
But apparently the methods I found: oPage.removeAllContent(); and oPage.destroyContent(); don't actually remove the old content completely because I'm still getting the error that I'm trying to add an element with a duplicate id:
Error: adding element with duplicate id 'text'
How can I remove the old content so that the old ids are actually forgotten and I can reinsert them?
Here's a minimal example (click the Reload button twice and on the second time the error will appear in the console):
https://jsfiddle.net/1Lqc36uh/
Here's the most relevant (I think) part:
let oPage = this.byId(this.detailId);
oPage.removeAllContent();
oPage.destroyContent();
if (bSetText) {
oPage.insertContent(new sap.m.Text(this.textId, {
text: "SetText"
}));
} else {
oPage.insertContent(new sap.m.Text(this.textId, {
text: "Test"
}));
}
Delete the line oPage.removeAllContent();.
The issue is that you're removing the content and then trying to destroy it:
oPage.removeAllContent(); // removes the existing content (without destroying it).
oPage.destroyContent(); // tries to destroy but there is no content!
The ManagedObject method destroyXYZ() relies on the fact that the child controls exist as part of the aggregation in the first place.
Removing the controls by removeAllXYZ() does remove them from the UI and makes them no longer related to the parent, but they're not destroyed and still in the control registry. Hence, the "duplicate ID" error.
The method destroyContent() is sufficient to remove the content from the UI and from the control registry.
Do you really need to give each element an ID? Most things can be done without an ID in UI5. Usually a JSONModel is the better approach to control UI elements.
For example you can make the first element visible and the second invisible (even using the same property in the JSONModel so both elements are automatically toggled).
That being said you can destroy the removed elements themself.
oPage
.removeAllContent()
.forEach(oControl => { oControl.destroy(); });
Edit: You can unaccept this answer, seems like #Boghyon gave a better one.
Okay, I'm not sure if I can explain this well.
This is what it looks like at runtime:
The list of display items from above are the data that came from database query.
I put a 'When mouse click' trigger to every row so that when I click a row, it copies all the data to the field below. It works when I first try to click a row but when I click another row which supposed to change the data below, NOTHING HAPPENS anymore.
here is my canvas' variable names:
here is what's inside of the 'When mouse click' trigger:
thank you for the help!
Your mouse click code is not working because when you are clicking on search block then currently you are in that block so you should have to move to FLIGHT block before assigning the values also you have to move to next record to populate the values into new record otherwise it will rewrite the values on existing, below is the example given for your problem:
on mouse click add these lines before your code
Begin
Go_Block('flight');
loop
if flight.flight_id is null then
-- look for the empty record if found then exit and assign values
exit;
end if;
-- else continue finding empty record
next_record;
end loop;
end;
--- paste your mouse click trigger code below
I got it. This tiny line of code did the trick.
GO_ITEM(SYSTEM.MOUSE_RECORD);
it simply tells what row number the item you clicked inside the record is in. It gives a char value of zero '0' when you clicked an item outside the record.
For more uses of the SYSTEM variables, check this very useful link. Thanks!
http://oraclet.blogspot.com/2008/02/system-variables-toutorial.html
I have tried this code but it works for once but not every time.
$('.rptEmail').attr('data-ignore','true');
$('.rptEmail').attr('data-hide','all');
$('#ReportMainGrid').trigger('footable_redraw');
I have tried other trigger also but nothing works properly.
I'm surprised no one else has had this problem. After pecking around the code, it looks like the data attributes for the rows are pulled using the .data() jquery function. The problem with this is (from what I understand) the function will populate on initial page load. What this means is, even though you change the data-hide attribute with .attr(), .data() will still hold the old value.
To get around this, without touching the Footable code, you can simply use the .data() function to change the column's property.
$("PATH_TO_TH").data("hide", "all"); //Set this to whatever you'd like
$('.footable').data('footable').reset();
$('.footable').footable();
If you want to use FooTable functions you can do this:
FooTable.get('#FooTable_ID').columns.get(col_id).visible = false;
FooTable.get('#FooTable_ID').draw();
where col_id is the index of the column you want to work with.
Sorry to jump in on this very old question but a much simpler method is to call .toggle or .hide/.show via jquery:
$('table td:nth-child(1),th:nth-child(1)').hide();
The above code will hide the header and the associated column rows.
I have a DataGrid with a TextInputCell column, using a ListDataProvider. When the value in a cell is changed I am creating a RequestContext and calling RequestContext#edit with the original entity for the row that is being edited. I then set the field in the mutable version of the proxy to the value from the edited cell. This all works nicely, and I can save the change successfully to the database. However, on the server I modify the value before saving the change, and send the modified entity (DTO) back to the client. In the Receiver#onSuccess method I store the new entity in the list data provider, and then call ListDataProvider#refresh. But the value that is shown in the DataGrid doesn't change to reflect the modification on the server. I've looked at the value that is supplied to the TextInputCell#getValue method, and it is correct, that is, it is the value that contains the modification applied on the server.
I tried creating another column in the grid that is just a TextCell, and supplied the same value in getValue for that cell; in this case the displayed value is correctly updated by the refresh, reflecting the modified value that was returned from the server.
So, my question is: where does the cell get its value? When I look at the value returned by my TextInputCell#getValue method it appears to be the correct value, but that value is not being shown on the screen (the value shown on the screen is the value that was in the proxy object prior to sending the request to the server).
Note: I looked at this question, but it did not work in my situation.
I have a very similar problem.
I have a page showing a grid with two column: the first one has check boxes instead of text.
The value of the check box is given by:
public Boolean getValue(Item item) {
return selectedItems.contains(item);
}
When the user checks a check box, I store the value in a map (selectedItems).
At the bottom of the page there is a "Clear" button that reset the map and calls the table redraw, but the status of the check boxes does not revert to the original status (i.e. the check boxes stay selected).
Debugging the code I've found that getValue() returns the correct value, but is like the table caches the cells.
The only workaround I have found, without rebuilding the whole table, was to remove the check boxes' cell and add it again on "Clear".
itemsTable.removeColumn(0);
itemsTable.insertColumn(0, makeSelectionColumn());
The method makeSelectionColumn() must return a new cell.
I'm looking for a widget which can be dynamically resized. I need to append and remove rows.
There are a methods coming with Grid, like gtk_grid_insert_row or gtk_grid_insert_next_to, but I don't find any xxx_remove_xxx method.
I'm developing a simple http client (to test an api). And I'm adding the possibility to append and remove "GET" variables dynamically.
The UI is made with rows containing a combobox (for variable selection), an entry (for its value) and on the last row a remove button.
Every time I set a variable, a new line (new available variable) is appended.
And every time I unset a variable, the corresponding line is removed.
thanks.
Gtk.Grid doesn't have a remove method; but Gtk.Container does. Since Grid is a Container, you can use gtk_container_remove.
The docs for this are here:
https://developer.gnome.org/gtk3/3.8/GtkContainer.html#gtk-container-remove
I think the widget you are looking for is Gtk.ListBox. It's a container so you can add and remove rows easily.