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

Redirect to other view when user does double click on row

Hi,

I want that, when a user does double click on a grid's row, a new page is loaded  with details of the row.

Index View

<div class="row panel">
    <div id="categories" class="col-xs-3">
        @(Html.EJ().Grid<EntitiesInforme.SP.DetallesInformeSemanal>("FlatGrid")
            .Locale("es-ES")
            //.Datasource((IEnumerable<object>)ViewBag.DSInforme)
            .SelectionType(SelectionType.Single)
            .AllowPaging()
            .AllowScrolling()
            .Columns(col =>
            {
                col.Field("ID").HeaderText("ID").Visible(false).Add();
                col.Field("NIS").HeaderText("NIS").Width(100).Add();
                col.Field("FechaGeneracion").HeaderText("FechaGeneracion").Visible(false).Add();               
            })
            .ClientSideEvents(eve =>
            {
                eve.RecordDoubleClick("onDoubleClick");
            })

        )
    </div>

 <script type="text/javascript">

    onDoubleClick = function(args)
    {
        var source = Object.keys(args.data);      

        $.ajax({
            url: "/Informes/InformeSemanal/Detalles",           
            type: "GET",
            data: { 'id': args.data["ID"] },
            dataType: "json",           
            contentType: "application/json; charset=utf-8",
            success: function (data) {
                if (data.RedirectUrl) {
                    window.location = data.RedirectUrl;
                } else {
                    // replace the context of the section with the returned partial view
                    $('#upload_section').html(data);
                }
            }
}

Controller

 public ActionResult Detalles(int? id)
{
            ViewBag.DSDetalles = db.GetDetallesInformeSemanal((int)id);
            return View("Detalles");
}

The action "detalles" is working, but does not redirect me to the page.

Thanks


3 Replies

RU Ragavee U S Syncfusion Team August 13, 2015 09:57 AM UTC

Hi Manolo,

We have analyzed the reported query. In the code that you have shared, we found that you have checked a condition inside the success event of the ajax call. The data returned from the view page in ajax success event is the corresponding partialview page “Detalles”. The argument data of the success function will have the partial view page html content and so the data.RedirectURL will be false always.

We suggest you to use the below code in order to direct to another page on recordDoubleClick event of the grid. Please refer the below code snippet.

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

    . . . .    

    .ClientSideEvents(eve=>eve.RecordDoubleClick("recordDblClick"))  

)


<script type="text/javascript">   

    function recordDblClick(args) {

        window.location = "/Home/RowDetails/?ord="+args.data["OrderID"];

    }
</script>

public ActionResult RowDetails(int ord)

        {

            var data = new NorthwindDataContext().OrdersViews.Where(e => e.OrderID == ord).FirstOrDefault();

            return View("_details", data);
        }


For your convenience, we have created a sample with the above solution and the sample can be downloaded from the below location.

Sample Link: http://www.syncfusion.com/downloads/support/forum/119910/ze/Sample-1237813112

Please try the sample and get back to us if you need any further assistance.

Regards
Ragavee U S


MA Manolo August 13, 2015 12:18 PM UTC

Thanks a lot


AS Alan Sangeeth S Syncfusion Team August 14, 2015 05:33 AM UTC

Hi Manolo,
 
Thanks for the update.
 
Please let us know if you need any further assistance. We will be happy to help you out.
 
Regards,
Alan Sangeeth S

Loader.
Live Chat Icon For mobile
Up arrow icon