I've broken my mind with Kendo library. I'm trying to do something like that:
c.Bound(m => m.Transaction).Title().ClientTemplate(Html.TransactionStateFormat(*currentValue*);
And my Html helper below:
public static string TransactionStateFormat(this HtmlHelper helper, TransactionState value)
{
string result;
switch (value)
{
case TransactionState.Applied:
result = "# <img src='/Content/img/checkbox-circle-small-2.png'/> #";
break;
case TransactionState.OptOut:
result = "# <img src='/Content/img/cross-sircle-small.png'/> #";
break;
case TransactionState.Undefined:
result = "# N/A #";
break;
default:
result = "# N/A #";
break;
}
return result;
}
The question is how to get current value of Transaction
to put it in to the html helper method? Or how to make the same thing by another way? Any suggestions?
You can use the following
c.Bound(m => m.Transaction).Title().ClientTemplate("#=TransactionStateFormat(data)#");
public enum TransactionState: int
{
Applied = 0,
OptOut=1,
Undefined=2
}
and you add this javascript function
<script>
function TransactionStateFormat(data)
{
var result='';
switch (data.Transaction)
{
case 0:
result = "<img src='/Content/img/checkbox-circle-small-2.png'/>";
break;
case 1:
result = "<img src='/Content/img/cross-sircle-small.png'/>";
break;
case 2:
result = "N/A";
break;
default:
result = "N/A";
break;
}
return result;
}
</script>
hope it will help you
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.