We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Gridtree: Adding rows

Hello,

How to add a row as child of the selected row by javascript?

I use this code:

 var Record ={ IdRow: createGuid(), Nombre: 'Nueva', ID: '', IdParent: treegObj.selectedItem().IdRow };
  treegObj.addRow(Record, ej.TreeGrid.RowPosition.Below);

Thanks!

7 Replies

DK Dinesh Kumar Nagarathinam Syncfusion Team November 16, 2015 02:55 PM UTC

Hi Jorge,

We can add a new row as child, by setting “RowPosition” enumeration value as “Child”.

Code Snippet:


<script type="text/javascript">  

            function addNewRow() {

                var treeObject = $("#Treegrid").data("ejTreeGrid");

                var newRecord = { Id: 10, Name: "childTask", StartDate: "02/23/2014", EndDate: "02/27/2014" }

                treeObject.addRow(newRecord, ej.TreeGrid.RowPosition.Child);               

            }
        </script>


We have prepared a sample based on your requirement, find the sample from below location.

Sample: http://www.syncfusion.com/downloads/support/forum/121139/ze/Add_child_Row407766024

Please let us know, If you need further assistance on this.

Regards,

Dinesh kumar.N



JP Jorge Pampin November 17, 2015 09:13 AM UTC

Hello,

It works perfectly. But, the primary key column (IdRow) is a Guid datatype, and when I create a new row the GridTree changes the value of the IdRow column from Guid to integer, why?

Thanks!


DK Dinesh Kumar Nagarathinam Syncfusion Team November 18, 2015 12:50 PM UTC

Hi Jorge,

If data type of the primary key column (IdRow) is GUID, then the id of newly added record has also to be a GUID data type. We have prepared a sample based on your requirement, Find the sample from below location.

Sample: http://www.syncfusion.com/downloads/support/forum/121139/ze/TreeGridSample_with_GUID-1479806403

Please let us know, if you need further assistance on this.

Regards,

Dinesh kumar.N



JP Jorge Pampin November 18, 2015 02:24 PM UTC

Hello,

You can reproduce it if you changes ChildMapping="Children" for IdMapping="Id" ParentIdMapping="IdParent". IdParent is a new field of BusinessObject class. I need to use IdMapping and ParentIdMapping properties.

Thanks!




DK Dinesh Kumar Nagarathinam Syncfusion Team November 19, 2015 04:52 PM UTC

Hi Jorge,

Do you want to generate GUID for IDRow automatically when we add a new row using toolbar?. For clarification, please find the below screenshot,

Screenshot: http://www.syncfusion.com/downloads/support/forum/121139/ze/Screenshot-438427437

Please let us know, if you need further assistance on this.

Regards,

Dinesh kumar.N



JP Jorge Pampin November 19, 2015 05:30 PM UTC

Hello,

My problem is that the treegrid changes the value of the GUID to an integer value. I create the new rows by javascript:

  var Record = { IdCuenta: createGuid(), Nombre: TextoNuevaCarpeta, ID: '', IdPadre: treegObj.selectedItem().IdCuenta };
  treegObj.addRow(Record, ej.TreeGrid.RowPosition.Child);

IdCuenta has an GUID value, but when it is shown on the treegrid, the value changes to autogenerated integer value.

Thanks!


DK Dinesh Kumar Nagarathinam Syncfusion Team November 20, 2015 08:39 AM UTC

Hi Jorge,

We regret for the inconvenience caused.

We were able to reproduce the issue while adding new row using public method with GUID data type and we have confirmed this as bug and logged a report on this. Also we have created a support incident under your

account to track the status of this issue.

Please log on to our support website to check for further updates.

https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents

Please let us know if you require further assistance on this.

Regards,

Dinesh kumar.N


Loader.
Up arrow icon