Question

I'm a beginner in MVC. I have a column which must be shown as a picture (now it is a text) and also when user click to picture it shows the dialog with new view. As i googled, i can use formatter only one time, what should i use then to implement it?

{ name: 'SimType', label: 'SimType', template: columntemplates.textTemplate, width: 50, editable: true, editrules: { edithidden: false }, formatter: linkFormat2, unformat: linkUnFormat2, editoptions: { disabled: 'disabled' } },


function linkFormat2(cellvalue, options, rowObject) 
{
  var linkUrl = '@Url.Action("GetMobilePhoneModels", "MobilePhoneModel", new { phonenumber = "Id" })'.replace('Id', rowObject['PhoneNumber']);
  return '<span class="MobilePhoneModel"><a href="' + linkUrl + '">' + cellvalue + '</a></span>';
}

OR

function linkFormat2(cellvalue, options, rowObject) 
{
  var cellValueInt = parseInt(cellvalue);
  if (cellValueInt = "mobile")
  return "<img src='../../Content/Images/Devices/mobile.png' width='11px' height='20.75px' alt='" + cellvalue + "' title='" + cellvalue + "' />";
}

it works separatly, but not possible together.

Any help is appreciated. Thanks.

Was it helpful?

Solution

i solved it by combining, if somebody need:

function linkFormat2(cellvalue, options, rowObject) {
      var cellValueInt = parseInt(cellvalue);
      if (cellValueInt = "mobile")
      {
                    var linkUrl = '@Url.Action("GetMobilePhoneModels", "MobilePhoneModel", new { phonenumber = "Id" })'.replace('Id', rowObject['PhoneNumber']);
                    return '<span class="MobilePhoneModel"><a href="' + linkUrl + '"><img src="../../Content/Images/Devices/mobile.png" width="11px" height="20.75px" alt="' + cellvalue + '" title="' + cellvalue + '" /></a></span>';
      }                    
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top