Treegrid multiple checkbox selection and get id of each row

Hi,

   I am using EJ2 treegrid control and trying to get courseid of selected checkbox. but not able to getting multiple ids at once either client side or server side.

Here is my treegrid 

<ejs-treegrid id="TreeGrid" dataSource="ViewBag.Courses" toolbar="@(new List<string>() { "Search" })" allowPaging="true" allowSelection="true" allowFiltering="true" height="350" childMapping="Children" treeColumnIndex="1" rowSelecting="rowselecting" detailTemplate="#detailtemplate">

       <e-treegrid-selectionsettings persistSelection="true" ></e-treegrid-selectionsettings>

    <e-treegrid-filtersettings type="Excel" hierarchyMode="Both"></e-treegrid-filtersettings>

        <e-treegrid-pagesettings pageSizes="true" type="Multiple" mode="Row" pageSize="10"></e-treegrid-pagesettings>

                    <e-treegrid-columns>

            <e-treegrid-column field="CourseId" showCheckbox="true" isPrimaryKey="true" field="isSelected" width="50"></e-treegrid-column>

                        <e-treegrid-column field="CourseId" headerText="Course ID" textAlign="Right" width="80"></e-treegrid-column>

                        <e-treegrid-column field="CourseUniversity" headerText="University" width="200"></e-treegrid-column>

                        <e-treegrid-column field="CourseName" headerText="Name" textAlign="Right" width="100"></e-treegrid-column>

                        <e-treegrid-column field="CourseCountry" headerText="Country" textAlign="Right" width="90"></e-treegrid-column>

                        <e-treegrid-column field="CourseCampus" headerText="Campus" textAlign="Right" width="90"></e-treegrid-column>

                    </e-treegrid-columns>

                </ejs-treegrid>


TreeGrid binded with ViewBag. Hereis my Model class


 public class CourseFinder

    {

        [Key]

        public int CourseId { get; set; }


        public string CourseUniversity { get; set; }



        public string CourseName { get; set; }


        public string? CourseWebUrl { get; set; }


        public string? CourseCampus { get; set; }


        public string? CourseCountry { get; set; }


        public string? CourseDuration { get; set; }


        public string? CourseStudyLevel { get; set; }


        public string? CourseIntake { get; set; }


        public string? CourseEntryRequirment { get; set; }


        public string? CourseIELTSOverall { get; set; }


        public string? CourseIELTSNoLess { get; set; }


        public string? CourseTofelOverall { get; set; }


        public string? CourseTofelNoLess { get; set; }


        public string? CoursePTEOverall { get; set; }


        public string? CoursePTENoLess { get; set; }


        public string? CourseFees { get; set; }


        public string? CourseRemarks { get; set; }


        public string? CourseWebometricsWorldRanking { get; set; }


        public string? CourseWebometricsNationalRanking { get; set; }


        public string? CourseApplicationDeadline { get; set; }


        public decimal? CourseApplicationFees { get; set; }


    }



I tried solution from https://www.syncfusion.com/forums/160748/treegrid-checkbox-selection-load-and-save-from-controller but not working getting beforeDataBind not recoginize. 


Thanks in advance


1 Reply

FS Farveen Sulthana Thameeztheen Basha Syncfusion Team October 3, 2022 03:25 PM UTC

Hi Gulab Chand,


As we have mentioned in the forum 160748 we suspect that you need to display type checkbox column to behave like autoCheckHierarchy. In our TreeGrid we can have checkbox column support(supports hierarchy) by enabling autoCheckHierarchy property as true. This property mainly checks the checkboxes based on Hierarchical order. Click on any parent record checkbox then the child record checkboxes will get selected and parent record checkbox will get selected while checking all of its child items.


Refer to the documentation and Demo Links:- 

https://ej2.syncfusion.com/aspnetcore/TreeGrid/CheckboxColumn#/material

https://ej2.syncfusion.com/aspnetcore/documentation/tree-grid/columns-core#checkbox-column


Or you want to dynamically select the checkboxes, you can use selectCheckboxes method of the Treegrid.

https://ej2.syncfusion.com/documentation/api/treegrid/#selectcheckboxes


If you want to perform multiple checkbox selection we suggest to use type checkbox property of the column as we have provided solution in this Sample link

https://ej2.syncfusion.com/aspnetcore/TreeGrid/CheckboxSelection#/material

https://ej2.syncfusion.com/aspnetcore/documentation/tree-grid/selection/check-box-selection


If we misunderstood your query please share detail Explanation/Screenshots of you requirement to proceed further.


Regards,
Farveen sulthana T


Loader.
Up arrow icon