Get new parentId of row after drag and drop in ej2-treegrid - vue.js

I have a syncfusion treeGrid component with drag and drop activated. When a component is dropped I would like to know what row is gonna be the parent after the drop (what's the new parentId).

Searching the documentation, you have these events that fire from drag and drop actions. Sounds like you want to listen to rowDrop event. This event will provide these event arguments, of which I think you want dropIndex property. With the index of the row dropped on you should be able to look up the id and other information in your rows data array.

From using getCurrentViewRecords method, we can get the ParentItem or ParentID of the dropped Child with Children property of that record and if it is dropped as Parent, ParentItem remains undefined. You can get the details from actionComplete event of the TreeGrid after rowDrag and drop operation.
Refer to the documentation lInk:
https://ej2.syncfusion.com/vue/documentation/api/treegrid/#getcurrentviewrecords
https://ej2.syncfusion.com/vue/documentation/api/treegrid/#rowdrop

Related

Parent-Child Checkbox in Material Checkbox

I have two cases that I want to implement:
[]Checkbox1
[]checkbox1.1
[]checkbox1.2
If I select parent node checkbox1 it should not select it's children.
If I select both the child, it should not select parent.
I am using mat checkboxes, any idea how it can be achieved.
I don't believe that Material Component has this logic it self, at leats yet, look here, there is an issue reported:
https://github.com/material-components/material-components-android/issues/857
If you wanna extend the Material Check Button and add you the logic you can do it, have a look into this answer:
Creating a three states checkbox on android

Aurelia Validation and event publish not updating values in View

I was using Event aggregate publish method to update view from another view. when I created publish and subscribe data was able to get in view model , but that is not updating in view with assigned variables. If I use JavaScript to fill value it's working but not able to trigger validate controller.
Expected result is:
From the subscribe method I have to fill the view values.
After that it should trigger validate on value changes.
In below gist run I have two view and view-model. One is registration-form and second one is data-form. In data-form I have table with data, on click of each row I am publishing one event with selected row data, and this published event I was subscribing in side of registration-form view-modal. For more details look into below gist run.
Gist run: https://gist.run/?id=8416e8ca1b9b5ff318b79ec94fd3220c
Two possible solutions: (to your "undefined" alert)
Change alert(this.email); to alert(myself.email);
Use the thick arrow syntax for the subscribe function. Change:
this.ea.subscribe('MyrowData', function(obj){
to
this.ea.subscribe('MyrowData', obj => {
This syntax allows the new function to preserve the context/scope of the parent, which means that this.email will still be accessible.
Another suggestion:
You could simplify your data-form.js function as follows:
Change:
this.eventAggregator.publish('MyrowData', this.items[this.items.indexOf(item)]);
to:
this.eventAggregator.publish('MyrowData', item);
This will work because you've already provided item in your function call click.delegate="PopulateData(item, $event)".
In fact, you could even delete $event and event from the two PopulateData definitions (in data-form.js and data-form.html).
When I implement these suggestions, your data is also validated correctly.

How to trigger the ALV DATA_CHANGE event manually?

I have an instance of CL_GUI_ALV_GRID referenced by variable mo_alv_grid.
I have a button column in this grid, which after some logic, updates the table mt_alv_grid (backing mo_alv_grid).
I need to be able to trigger the event DATA_CHANGED at this point.
I have tried many methods of CL_GUI_ALV_GRID, like CHECK_DATA_CHANGED and REFRESH_TABLE_DISPLAY
and even CL_GUI_CFW=>FLUSH and CL_GUI_CFW=>SET_NEW_OK_CODE( 'ENTER' ). but none of this has worked.
Is there a way to trigger the DATA_CHANGED event, or should I be doing things completely differently ?
I don't know if this solves your problem, but in order to update the ALV internal table in the PAI, you could use the following method:
DATA lv_entries_are_consisted TYPE abap_bool.
mo_grid->check_changed_data(
IMPORTING
e_valid = lv_entries_are_consisted
).
well, it's possible.
1) don't change values in internal table by program
2) create a change protocol of type LVC_T_MODI with a new values for lines needed
then call
CALL METHOD lo_grid->change_data_from_inside
EXPORTING
it_style_cells = lt_cells.
where lo_grid is instance of cl_gui_alv_grid and lt_cells table type LVC_T_MODI. please note, that you will need to set field VAL_DATA of layout structure (LVC_S_LAYO) to 'X' when calling ALV grid for the first time to make this work.
after this, class will automatically change internal table for you and call DATA_CHANGE event

dojox.grid.DataGrid: how to access data from a click event?

I'm using Dojo 1.5 (including dojox). I have a dojox.grid.DataGrid where each row represents a user. When I click a row, I want to redirect to a URL like /users/USER_ID. The user ID is one of the fields in the grid, so all I need to do in my onRowClick callback is to grab the user ID for the row that was clicked.
The click event contains a rowIndex property, and, indeed, I found a (rather old) post elsewhere that suggested I should be able to do:
var row = dijit.byId('grid').model.getRow(e.rowIndex);
/* (Then grab the 0th field of the row, which is the user ID.) */
(Sorry, I've since lost the URL.)
But my grid object has no model attribute. What's up with that? Has the API changed? (My grid certainly is populated with data, which I can see, click, sort by column, et cetera).
So I'm stuck for now. Note, BTW, that it won't work to use rowIndex to directly access the grid's underlying dojo.data.ItemFileReadStore. That's because the grid is sortable, so there's no guarantee that the grid's rows will be in the same order as the store's.
Any hints would be deeply appreciated. I hope that the question is clear, and sufficiently general that any answers can help others in my predicament. Many thanks.
I have a similar scenario and I grab the value like this:
onRowClick: function(e) {
open_link(my_grid._getItemAttr(e.rowIndex, 'object_path'));
}
In this case my_grid is a reference to the datagrid and object_path is the column where I store the path to the object. open_link is of course a custom function of mine that as it implies, requests a server path.
So just change the specifics to suite your case and you should be fine.

How to add a new node to a dijit.Tree

I want to add a new node to a dijit.ree as a sibling of the currently selected node. I've found sample code (I'm new to dojo) that adds a new item to the tree using the newItem method of ItemFileWriteStore, but the new item always appears at the bottom of the tree. How would I add to the store at a specified position, in particular the position corresponding to the current selection? Pointers to sample code would be welcome :)
Thanks,
Larry
You need to find the parent item of current selected node and use that item as the parent of the newly created item.
store.newItem(itemObj, {parent : parentItem, attribute : children});
Normally an item in the store doesn't have a back pointer points to its parent. So you may need to maintain that yourself. For example, you can store the parent item's id in the child item and use fetchItemByIdentity to get the parent item.
I figured it out; here's the answer for future searchers. Use newItem as Alex suggested. Then use model.pasteItem to reposition the new item. pasteItem takes a parent (selectedNode.item.parent[0]) and a position (selectedNode.getIndexInParent()+1)
Larry
store.newItem is giving an error (Uncaught Error: dojo.data.ItemFileReadStore: Invalid attribute argument. ). Could not really find a fix for this so far and my store does not have duplicate id's.
Hence i tried using model.newItem(newItem, parentItem).
This works perfectly alright.
Thanks,
Srilatha.