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.
Unfortunately, activation email could not send to your email. Please try again.

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

Thread ID:

Created:

Updated:

Platform:

Replies:

121031 Nov 4,2015 03:50 AM Nov 16,2015 11:22 PM ASP.NET Web Forms 8
loading
Tags: Grid
Manolo
Asked On November 4, 2015 03:50 AM

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

Ragavee U S [Syncfusion]
Replied On November 5, 2015 04:20 AM

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.

Manolo
Replied On November 5, 2015 12:45 PM

Hi, It works perfectly!!

But one question.

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

Thanks!

Ragavee U S [Syncfusion]
Replied On November 6, 2015 03:49 AM

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.

Manolo
Replied On November 13, 2015 07:15 AM

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.

Manolo
Replied On November 13, 2015 07:28 AM

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

Ragavee U S [Syncfusion]
Replied On November 15, 2015 11:26 PM

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.

Manolo
Replied On November 16, 2015 12:12 PM

Yeah!! Thank you very much!!



Ragavee U S [Syncfusion]
Replied On November 16, 2015 11:22 PM

Hi Manolo,

Thanks for your update.

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


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;