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
close icon

Hierarchical grid - Read specific cell with javascript

Hi,I have a hierarchical grid (two levels:parent rows and child rows).
On the left of the rows I have checkbox. My problem is to read one specific cell. Infact in the table I have:

Data | Mail | State | Id

and in javascript I would like to read the content of cell "id".(is more complex of this  but in brief this is the problem; I can't use c# code for this specific case but I must use only java).
Thanks in advance
Andrea

3 Replies

SS Satheeskumar S Syncfusion Team May 20, 2014 10:02 AM UTC

Hi Andrea,

Thanks for your interest in Syncfusion products.

We are glad to let you know that your requirement can be achieved. We have used RowBtnTemplate to add the Check Box to grid. We have hidden the header check boxes using java script. We have displayed the particular cell content, while check the checkbox.

Please refer the below code snippet.

<script type="text/javascript">

function BeginRequestHandler(sender, args) {

                                    $('input[id *="header"]').hide(); //To remove the check box from header

            }

            Sys.WebForms.PageRequestManager.getInstance().add_endRequest(BeginRequestHandler);   

 

            $(function () {

                                    $('input[id *="header"]').hide(); //to remove the check box from header

            });

            function checkchanged(oData) {

                                    var gridTable = GetEGridTable($get('<%= GridGroupingControl1.ClientID %>'));

                                    var gridObj = gridTable.GetGridObj();

                                    var colIdx = 0;

                                    for (tableName in gridObj.gridTables) {

                                    for (var i in gridObj.gridTables[tableName].visibleColumns) {

                                                var column = gridObj.gridTables[tableName].visibleColumns[i];

                                                if (oData.id.indexOf("NT") == -1) {

                                                             //Parent Grid

                                                             if (column.name == "Customer ID") {

                                                                          if (gridTable.showRowHeader)

                                                                                     colIdx = column.index - 1;

                                                                          else

                                                                                      colIdx = column.index;

                                                                           break;

                                                             }

                                                }

                                                else {

                                                              //Child Grid

                                                              if (column.name == "Ship Name") {

                                                                        if (gridTable.showRowHeader)

                                                                                     colIdx = column.index - 1;

                                                                        else

                                                                                    colIdx = column.index;

                                                                        break;

                                                              }

                                                 }

                                    } //end of loop

                        }

                        if (oData.checked) {

                                    selText = $(oData.parentElement).siblings().eq(colIdx).text();

                                    alert(selText);

                        }

            }

</script>

 

<syncfusion:GridGroupingControl EnableCallbacks="false" ID="GridGroupingControl1"

        <TableDescriptor AllowFilter="False" AllowNew="false" AllowEdit="false">

             <RowBtnTemplate>                                            

                        <asp:Checkbox ID="cbSelect" runat="server" onclick="checkchanged(this);"/>

             </RowBtnTemplate>

        </TableDescriptor>

</syncfusion:GridGroupingControl>

 

For your convenience we have attached the sample. Could you please use this sample and let us know if this is helpful.

Please let us know if you need any further assistance.

Regards,

Satheeskumar S


Attachment: Grouping_IssueData_Import_de8b884e.zip


AF andrea fanara May 23, 2014 01:37 PM UTC

Thanks Satheeskumar!


ES Eswari S Syncfusion Team May 26, 2014 07:10 AM UTC

Hi Andrea,

 

Thanks for your update. Please let us know if you need any further assistance.

 

Regards,

Eswari S

 


Loader.
Live Chat Icon For mobile
Up arrow icon