开发者

JQGrid + ASP.NET MVC 3 Redirect to record details on doubleclick

I have implemented a simple jqGrid in my ASP.NET MVC 3 application. It shows the data correctly, so that's fine. But now I want my application to show the details of a row if I doubleclick on a row. I have a Detail action method that actually gets called with the correct ID, the details are retrieved from database and the Details view is returned, so that seems to be OK, but in my application nothing happens.

I have the following script for the grid:

jQuery(document).ready(function ()
{
    jQuery("#list").jqGrid({
        url: '开发者_运维技巧/Incident/ListData/',
        datatype: 'json',
        mtype: 'GET',
        colNames: ['TicketNumber', 'Title', 'CreatedOn'],
        colModel: [
      { name: 'TicketNumber', index: 'TicketNumber', width: 75, align: 'left' },
      { name: 'Title', index: 'Title', width: 250, align: 'left' },
        { name: 'CreatedOn', index: 'CreatedOn', width: 90, align: 'left'}],
        pager: jQuery('#pager'),
        rowNum: 10,
        rowList: [10, 50, 100],
        sortname: 'CreatedOn',
        sortorder: "desc",
        viewrecords: true,
        width: 650,
        imgpath: '/Content/themes/base/images',
        caption: 'Incidents',
        ondblClickRow: function (id) { $.get('/Incident/Detail/' + id); }
    });
}); 

I've tried using $.ajax instead of $.get, but in both cases the details method gets called and nothing happens.

This is the Details action method

 public ViewResult Detail(Guid id)
    {
        var query = from inc in _repository.Incidents
                    where inc.Id == id
                    select
                        new IncidentModel(inc)
                            {
                                CreatedOn = inc.CreatedOn,
                                Description = inc.Description,
                                ModifiedOn = inc.ModifiedOn,                                    
                                TicketNumber = inc.TicketNumber,
                                Title = inc.Title,
                                Status = inc.Status
                            };
        var incident = query.FirstOrDefault();

        return View(incident);
    }


$.get sends an AJAX request and gives you the server's reply.
It doesn't actually do anything with the server's reply; it's up to you to do something useful.

It sounds like you don't want AJAX at all; instead, you want to navigate to that page:

location = '/Incident/Detail/' + id


As Slaks said, you're not doing anything with the content. Should your double click event actually be redirecting the browser to that action?

(Just a side note, why double click? Nearly everything else net based uses a single click to browse).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜