1

I want to add create action with some case, but I don't know the right syntax.

<script type="text/javascript">
$(document).ready(function () {
      $('#XXX').jtable({
        title: 'XXXXX',
        actions: {
            listAction: '@Url.Action("XXX")',
            createAction: '@Url.Action("XX","XXX")',
            deleteAction: '@Url.Action("XX", "XXX")',
            updateAction: '@Url.Action("XX", "XX")'
        },
        fields: {
            Id: {
                key: true,
                create: false,
                edit: false,
                list: false
            },
            Name: {
                title: 'Ad',
                width: '40%',
                inputClass: 'validate[required]'
            }
        }
    });
    $('#XXXX').jtable('load');
});

I mean as below : if user has authority, I want to add create action.

 actions: {
            listAction: '@Url.Action("XXX")',
           @if(true){ createAction: '@Url.Action("XX","XXX")',}
            deleteAction: '@Url.Action("XX", "XXX")',
            updateAction: '@Url.Action("XX", "XX")'
        }

Thank you.

ayse
  • 93
  • 8

1 Answers1

1

Based on this post, the following worked for me:

@if(true){
    <text>
    createAction: '@Url.Action("XX","XXX")',
    </text>
}
Community
  • 1
  • 1
poppertech
  • 1,286
  • 2
  • 9
  • 17