Question

My columns are showing up, it is generating an anchor for my link. The only problem is the url is badly formed for MVC

Here is the colModel:

                colModel: [

                  { name: 'RegName',  index: 'RegName', label: 'Region Name',width:90, align: 'center' },
                  { name: 'AccessNbr', index: 'AccessNbr', label: 'Access Number',width:80, align: 'center', formatter: 'showlink', formatoptions: {baseLinkUrl: '', showAction: 'GetBoxesForPorId', addParam: ''}  },
                  { name: 'TransmitedDt', index: 'TransmitedDt', label: 'TransmitedDt',  align: 'center' },
                  { name: 'BoxCount', index: 'BoxCount', label: 'Box Count', align: 'center' },
                  { name: 'PorId',  hidden:false ,index: 'PorId', label: 'Por ID', key:true ,formatter:'link', formatoptions: {target:'_new'}  }                           
                ]

Here is the url that it builds: http://localhost:4618/Por/GetBoxesForPorId?id=16

The url I want it to build is: http://localhost:4618/Por/GetBoxesForPorId/16

Was it helpful?

Solution

Here's your answer :

 function formateadorLink(cellvalue, options, rowObject) {

            return "<a href=/Idiomas/Edit/"+ cellvalue + ">" + cellvalue + "</a>";
        }

in the grid definition:

   colModel: [
                        { name: 'id_idioma', index: 'id_idioma', width: 100, align: 'left',
                            formatter: formateadorLink
                        },
                        { name: 'nombre', index: 'nombre', width: 100, align: 'left' }
                  ],

OTHER TIPS

This is the way I did it:

  function LinkFormatter(cellvalue, options, rowObject) {

            return '<a href= <%= Url.Content("~/") %>' + cellvalue + ">Edit</a>";
        } 

Col Model

  colModel: [
                    { name: 'Id', index: 'Id', width: 50, align: 'left', hidden: true },
                    { name: 'Edit', index: 'Edit', width: 50, align: 'left', formatter: LinkFormatter },
                    { name: 'AgentName', index: 'AgentName', width: 250, align: 'left' },
                    { name: 'AgentType', index: 'AgentType', width: 250, align: 'left' },
                ],

In the server side

    var jsonData = new
    {
        total = 1,
        page = 1,
        records = agents.Count(),
        rows = (
                from row in agents
                select new
                {
                    i = row.Id,
                    cell = new[] {


                        row.Id.ToString(),
                        "Controller/Action/" + row.Id.ToString(),
                        row.Name,
                        row.Type
                    }
                }).ToArray()

    };
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top