MVC 4, in JQuery grid one column has to be repalaced with picture and be link which opens JQdialog

StackOverflow https://stackoverflow.com/questions/17987107

سؤال

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.

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

المحلول

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>';
      }                    
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top