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 data from a double click

Hi, I am using a Grid with selection disabled, e.g.

@(Html.EJ().Grid<MyData>("results")
    ....... removed .....
    .AllowSorting()
    .AllowPaging()
    .AllowTextWrap()
    .AllowResizing()
    .AllowSelection(false)
    .PageSettings(page => page.PageSize(15))
    .EnableAltRow()
    .ClientSideEvents(evt => evt.RecordDoubleClick("recordDoubleClick"))
)

Is there any way to get the row data from which the user double click at? I would like to get a few column data (including hidden columns) for use inside the javascript function recordDoubleClick. BTW, I see that the columns width are equally divided from the grid width before the data is loaded from the datasource (which is a webapi call to the controller). I wonder if it is possible to use exactly the width I specified in the view?

1 Reply

PK Prasanna Kumar Viswanathan Syncfusion Team June 19, 2015 09:39 AM UTC

Hi William,

Thanks for using Syncfusion products.

Query: “Is there any way to get the row data from which the user double click?”

Yes, the row data from which the user double click can be received by using the event RecordDoubleClick. In this event, we can able to get the selected cell in arguments. So, using jQuery parent method we will be able to get the row data.

Please refer the following code example:

@(Html.EJ().Grid<object>("Grid")

              .Datasource(ds => ds.URL("/api/Orders").Adaptor(AdaptorType.WebApiAdaptor))

              .AllowSorting()

              .AllowPaging()

              .AllowTextWrap()

              .AllowResizing()

              .AllowSelection(false)

              .PageSettings(page => page.PageSize(10))

              .EnableAltRow()

              .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); })

                      .ToolbarSettings(toolbar =>

                   {

                       toolbar.ShowToolbar().ToolbarItems(items =>

                       {

                           items.AddTool(ToolBarItems.Add);

                           items.AddTool(ToolBarItems.Edit);

                           items.AddTool(ToolBarItems.Delete);

                           items.AddTool(ToolBarItems.Update);

                           items.AddTool(ToolBarItems.Cancel);

                       });

                   })

              .Columns(cols =>

              {

                  cols.Field("OrderID").IsPrimaryKey(true).Width(70).Add();

                  cols.Field("EmployeeID").IsPrimaryKey(true).Width(100).Add();

                  cols.Field("CustomerID").Width(90).Add();

                  cols.Field("Freight").Width(70).Format("{0:C}").Add();

                  cols.Field("ShipCountry").Width(60).Add();

              })

              .ClientSideEvents(evt => evt.RecordDoubleClick("recordDoubleClick"))

    )


While we set allowSelection as false, it throws script error in recorddoubleclick event. We considered this “Throws script error when we set allowselection as false in recorddoubleclickevent” as an issue and a support incident has been created under your account to track the status of this requirement. Please log on to our support website to check for further updates.

https://www.syncfusion.com/account/login?ReturnUrl=/support/directtrac/incidents

Query : “if it is possible to use exactly the width I specified in the view?”

Yes, it is possible to set the width in the view. We can able to set the width in the columns API. Please refer the above code example:

For your reference, we have created a sample and same can be downloaded from the below link: 
Sample Link : http://www.syncfusion.com/downloads/support/forum/119422/ze/WebApiSample_Modified-607651259

Please let me know if you need any further assistance.

Regards,
Prasanna Kumar N.S.V


Loader.
Up arrow icon