- Home
- Forum
- ASP.NET Web Forms
- get cell value and column name when double click on grid cell in script
get cell value and column name when double click on grid cell in script
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
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. } |
Regards,
Ragavee U S.
But one question.
Where is the documentation for javascript for cell object for example?
Thanks!
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.
This javascript function works fine without grid grouping.
If the grid has some aggrupation, this function doesn't works fine.
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. } |
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.
Thanks for your update.
We are happy that your requirement is achieved.
Regards,
Ragavee U S.
- 8 Replies
- 2 Participants
-
MA Manolo
- Nov 4, 2015 08:50 AM UTC
- Nov 17, 2015 04:22 AM UTC