首页 新闻 会员 周边 捐助

jqgrid如何直接在表格中修改数据。前后台如何处理,求解!

0
悬赏园豆:15 [已解决问题] 解决于 2014-09-22 18:58

比如我要直接在这个表格中修改时间,前后台如何办?还有这个时间怎么样才能显示分,秒?

renshen4322的主页 renshen4322 | 初学一级 | 园豆:5
提问于:2014-09-22 13:50
< >
分享
最佳答案
0

jqGrid显示数据,属性,多重表头,子表,行编辑,单元格编辑等 基本

仔细一看,你这个问题挺多的。

前后台如何办?我就不解答了,不知道你知道什么,没有办法解答。

收获园豆:15
爱编程的大叔 | 高人七级 |园豆:30844 | 2014-09-22 14:10

比如;

var varTime;
    var vm = {
        init: function () {   
             var lastsel2;
            $('#div-list').jqGrid({
                url: '@Url.Content("~/IDE/LatterAction/GetListInfo")?rid=@ViewBag.Rid',
                sortname: 'PfinishTime', 
                multiselect: false,            
                pager: $('#div-pager'),
                rowNum:10,   
                rowList:[10,20,30],
                height: '100%',
                colNames: ['编号','再鉴定名称','后续行动内容','负责人','计划完成日期','后续行动状态','录入人','最新进展','操作'],
                colModel: [
                    { name: 'LatterId', index: 'LatterId', hidden: true, key: true },                 
                    { name: 'Name', index: 'Name',align:'left', width:90,
                        formatter: function (cellvalue, options, rowObject) {
                            return '<a href="#" onclick="vm.view(\''+rowObject.IdentId+'\')">'+cellvalue+'</a>'; }
                    },                  
                    { name: 'LatterContent', index: 'LatterContent',align:'left',width:120},
                    { name: 'ChargePerson',index:'ChargePerson',align:'left',width:100},
                    { name: 'PfinishTime',index:'PfinishTime',align:'center', editable: true,width:100,formatter: 'date', datefmt: 'Y-m-d'},
                    { name: 'LatterState',index:'LatterState',align:'left',width:60},
                    { name: 'EnterMan',index:'EnterMan',align:'left',width:90},
                    { name:'NewMarch',index:'NewMarch',align:'left'},                   
                    { name: $.jgrid.defaults.cleverjqgridactions,sortable:false,width: 60,align: 'center',
                        formatter: function (cellvalue, options, rowObject) {
                            return '<div class="ui-btn-imgarea"><span title="删除" class="ui-icon ui-icon-delete" style="cursor:pointer" onclick="vm.remove(\'' + rowObject.LatterId + '\');"></span><span title="编辑" class="ui-icon ui-icon-edit" style="cursor:pointer" onclick="vm.update(\'' + rowObject.LatterId + '\');" ></span></div>';
                        }
                    }
                ],
          onSelectRow: function(id){
          varTime = $('#div-list').getCell( id,"PfinishTime" );        
              if(id && id!==lastsel2){
               jQuery('#div-list').jqGrid('restoreRow',lastsel2);
               jQuery('#div-list').jqGrid('editRow',id,true);
               lastsel2=id;    
                  }
                 }, 
            editurl: '@Url.Content("~/IDE/LatterAction/GetListInfo")',
      loadComplete: function(){ 
            var ids = $('#div-list').getDataIDs();
      /////设定背景色     
   var ids = $('#div-list').getDataIDs();
   for ( var i=0; i<ids.length;i++ ){  
            var rowData = $("#div-list").getRowData(ids[i],{LatterState:"LatterState"})
            if(rowData.LatterState=="新生成"){
            $('#div-list').setRowData(ids[i],null,{ background:"#EACB48"});
            }
            if(rowData.LatterState=="跟踪中"){
            $('#div-list').setRowData(ids[i],null,{ background:"#93EDE0"});
            }
            if(rowData.LatterState=="已完成"){
            $('#div-list').setRowData(ids[i],null,{ background:"#D3DEDE"});
            }
            if(rowData.LatterState=="已取消"){
            $('#div-list').setRowData(ids[i],null,{ background:"#D3DEDE"});
            }
   }; 
              
  },       
         gridComplete: function(){
             $('#div-list').setGridWidth($(window).width()-3);
              }
            });      
            $('#div-list').jqGrid('navGrid', '#div-pager', { del: false, add: false, edit: false, search: false, refresh: false, view: false })
        },    
        remove: function (id) {
            $.dialog.confirm("您确定执行此次操作吗,删除后将无法恢复?", function () {
                $.post('@Url.Content("~/IDE/LatterAction/Delete")?id='+id, function (data) {
                    var json = $.parseJSON(data);
                    json.result?vm.search():$.dialog.alert(json.msg);
                })
            });
        },
        update: function (id) {
            $("#ifrm").attr("src",'@Url.Content("~/IDE/LatterAction/Update")?id='+id);
            $.dialog.show({width: 420,height: 310,title: "修改",content: $("#div-ifrm")});
        },
        view:function(iid){      
          window.location.href='@Url.Content("~/IDE/LatterAction/ShowDetail")?id='+iid;
        },       
        search: function () {
            var params = $.param({rid:'@ViewBag.Rid', word:$("#word").val(),state:$("#LatterState").val()});
            $('#div-list').jqGrid('setGridParam', { url: "@Url.Content("~/IDE/LatterAction/GetListInfo")?"+params, page: 1 }).trigger("reloadGrid");
        },stateRefresh:function(){
                  var params = $.param({rid:'@ViewBag.Rid', word:$("#word").val(),state:$("#LatterState").val()});
            $('#div-list').jqGrid('setGridParam', { url: "@Url.Content("~/IDE/LatterAction/GetListInfo")?"+params, page: 1 }).trigger("reloadGrid");
        }
    };

    $(function(){
        $("#btnSearch").on('click', vm.search);    
        $("#LatterState").on('click',vm.stateRefresh);  
        vm.init();  
      
    });上面是我的具体代码js中的,

我只想可以直接在这个jqgrid表格修改时间,还有这个时间如何可以显示小时,分钟,秒??

renshen4322 | 园豆:5 (初学一级) | 2014-09-22 14:18
其他回答(1)
0

博主解决了告诉我一声。。

crossover丶 | 园豆:202 (菜鸟二级) | 2017-04-17 16:30
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册