I'm having a lot of trouble getting adding and editing rows working in the treegrid and I was hoping you could help.
What I am trying to accomplish
I have a grid and I want to let the user choose to add child or parent rows by clicking buttons. When the row is added, they would be scrolled to that row and put into edit mode on the category textbox with the cell showing red as failing validation. I also need to add a unique ID as I add the reocrd.
1) When I add a record my buttons lose their css style as the grid is updating then it is restored when the grid is updated. Is there a way to avoid this?
When I call treegrid.AddRecord() this does not happen, but when I call with params it does
I also see that a refresh instead of an add event is fired when you call add record with params.
You can see this behavior by clicking these buttons
Add Child Record no Parameters - no flicker
Add Child Record with Parameters - flicker
I attached a screenshot with an example of this.
2) How can I programatically select a row to edit?
Unlike calling add record without parameters, which kicks the user into edit mode, calling it with parameters does not.
How can I find the row that was added and set it to edit mode? I see celledit, but I can't seem to find something like that for row edit.
3) How can I trigger validation on the textbox
When I click add child record with parameters, then double click to edit, the textbox is blank, but it is a required field. I would expect the textbox to highlight red to let the user know that the field is required and potentially even a pop up error message if they are focused in the cell, but it does not happen in this case.
4) How can I trigger validation on the entire treegrid
I would like to trigger the validation failing cells to red for the entire treegrid programatically... possibly by a save all button. How can I do this without using a toolbar button.
5) Is it possible to add the child to the top spot instead of the last spot?
I've attached a sample program to help illustrate the issues Im having. I couldn't include node_modules due to the upload size limitation.
Query1: When I add a record my buttons lose their css style as the grid is updating then it is restored when the grid is updated. Is there a way to avoid this? |
By default, addRecord method with no parameter it will shows the empty row in editing state. If you don’t want to row in editing state, then you need to pass the parameter.Please refer to the below API documentation,https://ej2.syncfusion.com/documentation/api/treegrid/#addrecord | |
2) How can I programatically select a row to edit?I see celledit, but I can't seem to find something like that for row edit. |
We achieved your query by using the event and selectRow, startEdit method of the treegrid.
Please refer to the below code snippet,
Note: Using startEdit method the selected row is moved to edited state
Please refer to the below API documentation,
| |
3) How can I trigger validation on the textbox |
We checked this query, but we are unable to reproduce the issue at our end.Please refer to the below screenshot,Please refer to the below video demo,https://www.syncfusion.com/downloads/support/forum/169153/ze/validate-1497650720 | |
4) How can I trigger validation on the entire treegrid |
To achieve your requirement by using toolbar click event.
In toolbarClick event we have called the Tree Grid endEdit() method. If tree grid is in editable state, you can save a record by invoking endEdit. Before saving a record its validate the edited or added rowData and its display the error message when it does not meet the required condition in that validation function. Please refer the below code example
Please refer to the below API documentation,https://ej2.syncfusion.com/documentation/api/treegrid/#endedithttps://ej2.syncfusion.com/documentation/api/treegrid/#toolbarclick | |
5. Is it possible to add the child to the top spot instead of the last spot? |
Based on your query, we suggest you use the newRowPosition as ‘above’ and pass the index as first child index. Please refer to the below code example,
|
1) I've attached a picture of the button behavior (where they lose their formatting) for this one. Is there a way to avoid it? I would also think that it is a bug that the grid fire a refresh event on action complete instead of an add when you call the addrecord with parameters.
2) Start edit works. Thanks!
3) I've attached no_validation_5a9c4feb.zip to illustrate what is happening. I add a new row. Then I click in the row and even though the column is required the validation message does not come up when I double click to edit or click off of the row.
Topic 6: #4 Did not work, but I believe that I found a bug in the controls. Could you confirm this is a bug and let me know if there is any workarounds for what I am doing?
I attached a video of this.
I click Add Child Record with no Parameters and the row is added.
I double click on the row. I fill in the required field. When i click away from the row or hit enter it does not exit edit mode, like it normally would. TreeGrid.EndEdit did not work to exit out as well.
Topic #5: I tried this with the code below and it adds the row in the right place, but the row is a parent row instead of a child row. How can I make it a child row instead?
Query1: I've attached a picture of the button behavior (where they lose their formatting) for this one. Is there a way to avoid it? |
We are able to reproduce the issue at our end. We are working on this query with high priority to find the feasible solution of your requirement. We will update with further details on or before October 5th 2021. | |
2) How can I programatically select a row to edit?I see celledit, but I can't seem to find something like that for row edit. |
We are glad to hear your query has been solved by our solution.
| |
3) I add a new row. Then I click in the row and even though the column is required the validation message does not come up when I double click to edit or click off of the row. |
Based on your code example, you are customizing the row while beginning of the editing action.(i.e action complete event with args.requestTypes as beginedit or add which is the cause of the issue.
Confirm whether you need to hide the column template button while beginning of the edit. | |
4) Did not work, but I believe that I found a bug in the controls. Could you confirm this is a bug and let me know if there is any workarounds for what I am doing? |
Based on your code example, you are customizing the row while beginning of the editing action.(i.e action complete event with args.requestTypes as beginedit or add which is the cause of the issue.
Confirm whether you need to hide the column template button while beginning of the edit. | |
5. I tried this with the code below and it adds the row in the right place, but the row is a parent row instead of a child row. How can I make it a child row instead? |
In your code snippet, you are set isParent property is set true. So added row is act as parent row. So, we suggest you set the isParent property as false.
| |
|
6. When i click add row with parameters it does not start in edit mode, unlike add record without parameters.
What's the best way to to put the row in edit mode after the add?
|
Based on your query, we suspect that you want to show the row as edit mode after the records added.
We suggest you e achieved your query by using the event and selectRow, startEdit method of the treegrid.
Please refer to the below code snippet,
Note: Using startEdit method the selected row is moved to edited state
Please refer to the below API documentation,
|
Query 1: Thank you for the update
Query 2: Solved
Query 3: I do need this. Thank you for identifying this as the issue. As this issue was causing me the greatest amount of confusion and trouble.
Query 4: Sounds like Query 3/4 are actually due to the same cause.
Query 5: That was correct and solved my issue. Thanks for the help here.
Query 6: Are there any tricks to identify what index the new record was added at? It's easy if it is getting added at the start of the row, but can be little bit confusing when it is added as a child at the bottom of the row.
Query1: I've attached a picture of the button behavior (where they lose their formatting) for this one. Is there a way to avoid it? |
On further analyzing in your sample, you are defining the class property in the button component. However, there is no class property in our button component. If you want to customize the button, we recommend that you use the cssClass property of the button. Please refer to the below code snippet,
Please refer to the below sample,
Please refer to the below API documentation,
Please refer to the below help documentation,
| |
Query 2: Solved |
We are glad to hear your query has been solved by our solution.
| |
Query 3: I do need this. Thank you for identifying this as the issue. As this issue was causing me the greatest amount of confusion and trouble.Query 4: Sounds like Query 3/4 are actually due to the same cause. |
we have created separated incident for this query. You can track the further updates on this query in below incident
Incident : 344406
| |
Query 5: That was correct and solved my issue. Thanks for the help here. |
We are glad to hear your query has been solved by our solution.
| |
6. Are there any tricks to identify what index the new record was added at? It's easy if it is getting added at the start of the row, but can be little bit confusing when it is added as a child at the bottom of the row. |
we have created separated incident for this query. You can track the further updates on this query in below incident
Incident : 344404
|
When you hit the button to add a row without parameters I'm still seeing the buttons briefly lose format even in the stackblitz. I've attached a screenshot.
For the add records with no parameters this does not happen. I believe it's because the grid fires a refresh event instead of an add event when you add a row with parameters.
if it actually worked could you give me an example of how would I modify the cssClass="e-outline" style?
|
…………………….
<e-column headerText="" width="100px" [allowEditing]="false">
<ng-template #template let-data>
<div *ngIf="data.hasChildRecords">
<button
ejs-button cssClass="e-custom" (click)="onAddChild($event)">
Add Child
</button>
</div>
</ng-template>
</e-column>
<e-column headerText="" width="100px" [allowEditing]="false">
<ng-template #template let-data>
<div>
<button ejs-button cssClass="e-custom" (click)="onDelete($event)">
Delete
</button>
</div>
</ng-template>
</e-column>
……………………………
App.component.css
.e-custom {
border-radius: 0;
height: 30px;
width: 80px;
}
.e-custom,
.e-custom:hover,
.e-custom:focus,
.e-custom:active {
background-color: #ff6e40;
color: #fff;
}
|
When i tried to access the download it said it was not associated with my account and blocked access.
I did navigate to the stackblitz you provided with the solution, and I am still seeing the issue with the buttons. I made a recording and attached it to show what I'm seeing.
1) When you add a row the buttons lose their format, then the format is restored.
2) This was no the original issue I was worried about, but I see that when the sample loaded the buttons had no format at all. I have seen this periodically in my development as well.
In the video you sent I see the issue happening. When you click Add record without parameters the buttons do not flicker into a state where the css is removed. When you click it with parameters the buttons the buttons flicker as they lose their css state then reset to their original state.
I'm guessing its related to the grid refresh event being called when you add with parameters as opposed to a grid add event being fired (which I also believe is a bug).
For the other issue where the grid is displayed without css styles it is intermittent. if I figure out how to reproduce it I'll write back.
|
App.component.html
<div class="col-lg-8 control-section">
<ejs-treegrid
#treegrid
…
>
<e-columns>
….
<e-column headerText="" width="100px" [allowEditing]="false">
<ng-template #template let-data>
<div *ngIf="data.hasChildRecords">
<button ejs-button class="e-btn" (click)="onAddChild($event)">
Add Child
</button>
</div>
</ng-template>
</e-column>
<e-column headerText="" width="200px" [allowEditing]="false">
<ng-template #template let-data>
<div>
<button ejs-button class="e-btn" (click)="onDelete($event)">
Delete
</button>
</div>
</ng-template>
</e-column>
</e-columns>
</ejs-treegrid>
</div>
|
This worked! Thanks for taking the time to work throught his with me.