[MVC] How to call function in controller, from ImageCommandColumn in view?

  1. #1

    [MVC] How to call function in controller, from ImageCommandColumn in view?

    I have a GridPanel, where one column has clickable icons. When a user clicks on one of these icons in some row, I want to call a function in my controller.

    In Views/Home/Index.cshtml, I have this:
    columnModel.Add(Html.X().ImageCommandColumn()
        .Commands(command => {
            command.Add(Html.X().ImageCommand()
                .CommandName("DoStuff")
        })
    );
    And I want to call this, in Controllers/HomeController.cs:
    public void DoStuff()
    {...}
    How do I do this?
  2. #2
    Figured it out:


    columnModel.Add(Html.X().ImageCommandColumn()
        .Commands(command => {
            command.Add(Html.X().ImageCommand()
                .CommandName("DoStuff")
        })
        .DirectEvents( directEvent => {
            directEvent.Command.Url = "~/Home/DoStuff";
        })
    );

Similar Threads

  1. [CLOSED] Call Javascript function after or from DirectEvents
    By zwf in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Oct 31, 2012, 6:06 PM
  2. MVC Add Controller / Strongly Typed View Bug
    By Doug.Morrow in forum 2.x Help
    Replies: 0
    Last Post: Aug 08, 2012, 10:03 PM
  3. [CLOSED] passing ext.net controls to controller function
    By AnulekhaK in forum 1.x Legacy Premium Help
    Replies: 11
    Last Post: Feb 16, 2012, 12:55 PM
  4. Replies: 8
    Last Post: Dec 23, 2011, 12:41 PM
  5. [CLOSED] Universal controller call in MVC
    By tiramisu in forum 1.x Legacy Premium Help
    Replies: 21
    Last Post: Oct 05, 2010, 9:16 AM

Tags for this Thread

Posting Permissions