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.

Redirect to other view when user does double click on row

Thread ID:

Created:

Updated:

Platform:

Replies:

119910 Aug 12,2015 01:00 PM Aug 14,2015 01:33 AM ASP.NET MVC 3
loading
Tags: Grid
Manolo
Asked On August 12, 2015 01:00 PM

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


Ragavee U S [Syncfusion]
Replied On August 13, 2015 05:57 AM

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

Manolo
Replied On August 13, 2015 08:18 AM

Thanks a lot

Alan Sangeeth S [Syncfusion]
Replied On August 14, 2015 01:33 AM

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

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.

;