[CLOSED] Adding .js file to a grid generated from controller Ext 3.1 razor

  1. #1

    [CLOSED] Adding .js file to a grid generated from controller Ext 3.1 razor

    Can you suggest how to add an external js file to a controller action that is generating a grid panel. Thank you

    
    public ActionResult UserList(string containerId)
    {
    
        var grid = this.BuildGridPanel()
    
    
        // grid.Listeners.AfterRender.Handler = "Ext.net.ResourceMgr.registerScript();";  
        // ==> Should I add the script to a handler or use something like MvcResourceManager.RegisterGlobalScript(
         
        //MvcResourceManager.RegisterGlobalScript(Url.Content("~/resources/js/scafold/gridcontact.js"));
    
    
        grid.AddTo(containerId);  
    
    
         return this.Direct();
    }
    Last edited by Daniil; Jun 19, 2015 at 4:36 PM. Reason: [CLOSED]
  2. #2
    i found a way to do it. not sure if it is right but it is working. please close.
  3. #3
    Hi @idrissb,

    Thank you for the update!

    If you post a solution, we could review if it is a correct approach and/or there is a better one.
  4. #4
    I used the following code in the grid.

    public ActionResult UserList(string containerId)
    {
    
             var grid = this.BuildGridPanel()
    
             grid.ResourceItems.Add(new ClientResourceItem { Path = Url.Content("~/resources/js/scafold/grid.js") });
    
             grid.AddTo(containerId);  
    
    
              return this.Direct();
    }
    Last edited by Daniil; Jun 19, 2015 at 4:35 PM.
  5. #5
    Thank you.

    That is a correct approach. I would use that.

Similar Threads

  1. Replies: 6
    Last Post: Jul 02, 2013, 3:31 AM
  2. [Razor] Populating form values from controller
    By machinableed in forum 2.x Premium Help
    Replies: 2
    Last Post: May 07, 2012, 10:42 AM
  3. [CLOSED] Get value from textfield in controller [Razor]
    By boris in forum 2.x Premium Help
    Replies: 3
    Last Post: Apr 10, 2012, 7:19 PM
  4. Replies: 2
    Last Post: Dec 15, 2011, 11:58 AM
  5. Replies: 5
    Last Post: Apr 12, 2011, 4:37 PM

Posting Permissions