سؤال

وبلدي الأعمدة تظهر حتى أنه يولد لمستثمر رئيسي لربط بلادي. وعنوان الموقع يتم تشكيل المشكلة الوحيدة سيئة للMVC

وهنا هو 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'}  }                           
                ]

وهنا هو رابط أنه يبني: HTTP: // المضيف المحلي: 4618 / بور / GetBoxesForPorId معرف = 16

وهذا رابط أريد أن بناء هو: HTTP: // المضيف المحلي: 4618 / بور / GetBoxesForPorId / 16

هل كانت مفيدة؟

المحلول

إليك الجواب:

 function formateadorLink(cellvalue, options, rowObject) {

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

وفي تعريف الشبكة:

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

نصائح أخرى

وهذه هي الطريقة التي فعلت ذلك:

  function LinkFormatter(cellvalue, options, rowObject) {

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

والعقيد نموذج

  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' },
                ],

في الجانب الخادم

    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()

    };
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top