在JQGrid中创建链接 [英] Creating a link in JQGrid

查看:55
本文介绍了在JQGrid中创建链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的JQgrid中创建一个列的所有单元格,该链接调用带有单元格值的javascript函数,以便在服务器端传递一些查询。我见过 jqGrid中的html链接栏
但是它没有用完。这就是我所拥有的,

I need to make all cells of a column, in my JQgrid, a link, which calls a javascript function with the cell value, to be passed for some query on the server side. I have seen html link column in jqGrid but it is not working out. here is what I have,

colModel:[
{name:'name',width:300,formatter:link}
]

,链接功能

function link(cellvalue, options, rowObject) {


alert('<a href="javascript:logForProv(\''+cellvalue+'\',\''+$('#datepicker1').val()+'\',\''+$('#datepicker2').val()+'\');">');
return "<a href='javascript:logForProv(\''+cellvalue+'\',\''+$('#datepicker1').val()+'\',\''+$('#datepicker2').val()+'\');'>";
        }

这样做我没有在列中获得任何数据,我也试过使用预定义的格式化程序链接和showlink,但它们将href和id附加到正在搞乱的URL。

Doing this I dont get any data in the column, I also tried using the predefined formatters link and showlink, but they are appending href and id to the URL which is messing up.

请帮助。

推荐答案

当点击 providerId 编辑列时,您将重定向到 editProvider
提及 formatter:editLink at providerId colModel for call editLink 功能。通过这种方式在jqGrid中创建链接。

When click on providerId edit column you will redirect to edit page of editProvider. mentionformatter: editLink at providerId colModel for call editLink function. In this way creating link in jqGrid.

代码:

$(document).ready(function(){
        //jqGrid
        $("#providerList").jqGrid({
            url:'<%=request.getContextPath() %>/Admin/getProvidersList',
            datatype: "json",               
            colNames:['Id','Edit','Provider Name'],
            colModel:[
                {name:'providerId',search:false,index:'providerId',hidden:true},
                {name:'providerId',search:false,index:'providerId', width:30,sortable: false, formatter: editLink},
                {name:'providerName',index:'providerName', width:200},
                rowNum:20,
                rowList:[10,20,30,40,50],
                rownumbers: true,  
                pager: '#pagerDiv',
                sortname: 'providerName',  
                viewrecords: true,  
                sortorder: "desc",  
        }); 
        $('#gridContainer div:not(.ui-jqgrid-titlebar)').width("100%");
        $('.ui-jqgrid-bdiv').css('height', window.innerHeight * .65);
        $('#load_providerList').width("130");   
        $("#providerList").jqGrid('navGrid','#pagerDiv',{edit:false,add:false,del:false},{},{},{}, {closeAfterSearch:true});
        $(".inline").colorbox({inline:true, width:"20%"});
    });
    function editLink(cellValue, options, rowdata, action)
    {
        return "<a href='<%=request.getContextPath()%>/Admin/editProvider/" + rowdata.providerId + "' class='ui-icon ui-icon-pencil' ></a>";
    }

这篇关于在JQGrid中创建链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆