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

get cell value and column name when double click on grid cell in script

Hi,

I want to obtain values when a user double click on a grid cell.

For example, in the next image



I need the cell value (13), the column name (40), and cell value of contrata(2510-orense)

I've defined my grid:

        <ej:Grid ID="gridDatos" runat="server"
            AllowPaging="True"  AllowScrolling="True" AllowSorting="True" AllowFiltering="true"  AllowSelection="true"
            Selectiontype="Single" EnableRowHover="true">

            <ClientSideEvents RecordDoubleClick="onDoubleClick" />
            <SelectionSettings SelectionMode="cell"  />

            <ToolbarSettings ShowToolbar="true" ToolbarItems="excelExport"></ToolbarSettings>
            <FilterSettings FilterType="Excel"></FilterSettings>           
            .....          
        </ej:Grid>

and script:

 function onDoubleClick(args)
 {
            alert(args.cell);
}

But I've troubles in getting the grid data from javascript, (I don't know).

I've revised your documentation for this event



But I don't know which are the cell methods and I can't find the information.

So, my questions are:

1. How can I get the values in javascript?
2.
where can I find the information from cell methods?

Thank you

8 Replies

RU Ragavee U S Syncfusion Team November 5, 2015 09:20 AM UTC

Hi Manolo,

We analyzed your requirement to get the selected cell details when the cell is double clicked.

We have created a sample, which can be downloaded from the below location.

Sample Link: http://www.syncfusion.com/downloads/support/forum/121031/ze/Sample-819719401

In the above sample, we have obtained the cell details from the event arguments using javascript. Please refer to the code snippet.

<ej:Grid ID="FlatGrid" runat="server" AllowSorting="True" AllowGrouping="true" AllowPaging="True" EnableRowHover="false" > 

        <ClientSideEvents RecordDoubleClick="doubleClick" />

        . . . . .

       </ej:Grid>


<script type="text/javascript">

        function doubleClick(args) {

            alert("Column Name: " + this.getColumnByIndex(args.cell.index())["headerText"]);// returns the corresponding column name

            alert("Cell Value: " + args.cell.text());// returns the corresponding cell value

            alert("Selected cell index: " + args.cell.index());//returns the corresponding cell index

            alert("OrderID column corresponding to the selected cell: " + this.getCurrentViewData()[args.cell.closest("tr").index()].OrderID);//returns the corresponding OrderID value.          

        }
    </script>


Regards,
Ragavee U S.


MA Manolo November 5, 2015 05:45 PM UTC

Hi, It works perfectly!!

But one question.

Where is the documentation for javascript for cell object for example?

Thanks!


RU Ragavee U S Syncfusion Team November 6, 2015 08:49 AM UTC

Hi Manolo,

As mentioned in the below online documentation, we will get the details corresponding to the record double clicked in the event arguments.

http://help.syncfusion.com/js/api/ejgrid#events:recorddoubleclick

The args.cell parameter of the recordDoubleClick event will return the jquery object of the current cell selected.
We have missed out to mention in the above documentation that args.cell is a jquery object. We have thus considered it as a UG improvement and a support incident has been created 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=/support/directtrac/incidents

Regards,
Ragavee U S.


MA Manolo November 13, 2015 12:15 PM UTC

Ups, I need reopen this post.

This javascript function works fine without grid grouping.

If the grid has some aggrupation, this function doesn't works fine.


MA Manolo November 13, 2015 12:28 PM UTC

The problem is for get the row values, not for the column value


RU Ragavee U S Syncfusion Team November 16, 2015 04:26 AM UTC

Hi Manolo,

Please use the below workaround in your sample in order to get the row details in recordDoubleClick event of the Grid.

<ej:Grid ID="FlatGrid" runat="server" AllowSorting="True" AllowGrouping="true" AllowPaging="True" EnableRowHover="false" >  

        <ClientSideEvents RecordDoubleClick="doubleClick" />

        . . . . .

       </ej:Grid>


<script type="text/javascript">

        function doubleClick(args) {

            . . . .

            alert("OrderID column corresponding to the selected cell: " + this.getCurrentViewData()[this.getIndexByRow(args.cell.closest("tr"))].OrderID);//returns the corresponding OrderID value.           

        }
    </script>


We have modified our previously updated sample with the above workaround, which can be downloaded from the below location.

Sample Link: http://www.syncfusion.com/downloads/support/forum/121031/ze/Sample_modified376578315

Regards,
Ragavee U S.


MA Manolo November 16, 2015 05:12 PM UTC

Yeah!! Thank you very much!!




RU Ragavee U S Syncfusion Team November 17, 2015 04:22 AM UTC

Hi Manolo,

Thanks for your update.

We are happy that your requirement is achieved.
Regards,
Ragavee U S.


Loader.
Live Chat Icon For mobile
Up arrow icon