Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 查看消息的最佳工具?_Jquery_Html_Asp.net Mvc - Fatal编程技术网

Jquery 查看消息的最佳工具?

Jquery 查看消息的最佳工具?,jquery,html,asp.net-mvc,Jquery,Html,Asp.net Mvc,我正在尝试使用asp.net mvc设置一个消息视图,该视图将显示收件箱等。对于此实现,使用什么工具比较好?好的,下面是我们如何使用jqGrid进行此操作的细节。这里的想法是以粗体显示未读邮件,并带有正文预览,如Outlook: jqGrid自定义格式化程序(此语法适用于jqGrid 3.5;早期版本不同: importanceFormatter: function(cellval, opts, action) { switch (cellval) { case -1:

我正在尝试使用asp.net mvc设置一个消息视图,该视图将显示收件箱等。对于此实现,使用什么工具比较好?

好的,下面是我们如何使用jqGrid进行此操作的细节。这里的想法是以粗体显示未读邮件,并带有正文预览,如Outlook:

jqGrid自定义格式化程序(此语法适用于jqGrid 3.5;早期版本不同:

importanceFormatter: function(cellval, opts, action) {
    switch (cellval) {
        case -1:
            {
                return '<img class="notificationImportanceIcon" alt="Low importance" title="Low importance" src="/Content/Images/lowimportance.png" />';
            }
        case 1:
            {
                return '<img class="notificationImportanceIcon" alt="High importance" title="High importance" src="/Content/Images/highimportance.png" />';
            }
    }
    return cellval;
},

recipientFormatter: function(cellval, opts, action) {
    if (cellval) {
        var html;
        var i = 1;
        for (i in cellval) {
            if (i == 0) {
                html = cellval[i];
            }
            else {
                html = html + '; ' + cellval[i];
            }
        }
        return html;
    }
    return cellval;
},

messageFormatter: function(cellval, opts, action) {
    if (cellval) {
        var subject = '<span class="notificationSubject">' 
            + (cellval.Subject || "") + '</span>';
        var body = cellval.Body || "";
        var read = cellval.IsRead;
        var html;
        if ((body !== "") && (!read)) {
            var maxLength = 200;
            var excerpt = body.length > maxLength ?
                body.substring(0, maxLength - 1) + "...." : body;
            html = subject + '<br /><span class="notificationBody" title="' 
                + body + '" >' + excerpt + '</span>'
        }
        else {
            html = subject;
        }
        if (!read) {
            html = '<span class="unread">' + html + '</span>';
        }
        return html;
    }
},
网格配置:

setupGrid: function(grid, pager, search) {
    grid.jqGrid({
        colNames: ['AltId', '', 'From', 'Subject', 'To', 'Received', 'Actions'],

        colModel: [
          { name: 'AltId', index: 'AltId', hidden: true },
          { name: 'Importance', index: 'Importance', width: 10, formatter: Vertex.Notification.List.importanceFormatter },
          { name: 'From', index: 'From', width: 50 },
          { name: 'NotificationMessage', index: 'Subject', width: 200, formatter: Vertex.Notification.List.messageFormatter, sortable: false },
          { name: 'Recipients', index: 'To', width: 50, formatter: Vertex.Notification.List.recipientFormatter, sortable: false },
          { name: 'Created', index: 'Created', width: 60, align: 'right', formatter: Vertex.UI.Grid.dateTimeFormatter },
          { name: 'ActionsAltId', index: 'ActionsAltId', width: 38, formatter: Vertex.UI.Grid.rowEditButtons, formatoptions: { buttons: { HideEdit: false} }, sortable: false }
        ],
        pager: pager,
        sortname: 'Created',
        sortorder: "desc"
    }).navGrid(pager, { edit: false, add: false, del: false, search: false });
    search.filterGrid(grid.attr("id"), {
        gridModel: false,
        filterModel: [{
            label: 'Search',
            name: 'search',
            stype: 'text'
            }]
        });
    }
};
LINQ到实体:

    [AcceptVerbs(HttpVerbs.Get), CacheControl(HttpCacheability.NoCache)]
    public ActionResult ListGridData(JqGridRequest gridRequest)
    {
        var q = (from n in Repository.SelectAll()
                 from nr in n.NotificationRecipients
                 where nr.Recipient.UserName.Equals(
                     LoggedInUserName, StringComparison.InvariantCultureIgnoreCase)
                 orderby n.Created descending
                 select new PresentationModel
                 {
                     Id = n.Id,
                     AltId = n.AltId,
                     ActionsAltId = n.AltId,
                     Importance = n.Importance,
                     From = n.Creator.Person.DisplayName,
                     Created = n.Created,        
                     Subject = n.Subject, //used for search
                     Recipients =  from r in n.NotificationRecipients
                                   select r.Recipient.Person.DisplayName,
                     NotificationMessage = new NotificationMessage
                     {
                         Body = n.Body,
                         Subject = n.Subject,
                         IsRead = nr.MarkedAsRead /*IsRead for current user*/ 
                     }
                 }).ToList().AsQueryable();
       return Json(q.ToJqGridData(
           gridRequest.ToGridPageDescriptor(new [] {"From", "Subject"})));
    }

您可以找到。

我们显示了一个带有jqGrid的收件箱,但您的要求是否符合我们的要求还不清楚。请用两句以上的句子来说明您的需求,好吗?这正是我的意思。如果我说得不太具体,我深表歉意。我所说的工具是插件。我实际上使用过jqGrid,但我对是否有更多更好的选择感兴趣.
    [AcceptVerbs(HttpVerbs.Get), CacheControl(HttpCacheability.NoCache)]
    public ActionResult ListGridData(JqGridRequest gridRequest)
    {
        var q = (from n in Repository.SelectAll()
                 from nr in n.NotificationRecipients
                 where nr.Recipient.UserName.Equals(
                     LoggedInUserName, StringComparison.InvariantCultureIgnoreCase)
                 orderby n.Created descending
                 select new PresentationModel
                 {
                     Id = n.Id,
                     AltId = n.AltId,
                     ActionsAltId = n.AltId,
                     Importance = n.Importance,
                     From = n.Creator.Person.DisplayName,
                     Created = n.Created,        
                     Subject = n.Subject, //used for search
                     Recipients =  from r in n.NotificationRecipients
                                   select r.Recipient.Person.DisplayName,
                     NotificationMessage = new NotificationMessage
                     {
                         Body = n.Body,
                         Subject = n.Subject,
                         IsRead = nr.MarkedAsRead /*IsRead for current user*/ 
                     }
                 }).ToList().AsQueryable();
       return Json(q.ToJqGridData(
           gridRequest.ToGridPageDescriptor(new [] {"From", "Subject"})));
    }