[CLOSED] [Razor] Parameter passing from DirectEvents

  1. #1

    [CLOSED] [Razor] Parameter passing from DirectEvents

    Hi

    I've created a combobox with a directEvent attached and defined the method in the controller which is called when the user selected a value.

    What is the best way to either:

    1) Pass the selected value into the Controller
    2) Access the selected value directly from Controller

    cshtml

    @(
      Html.X().ComboBox()
        .ID("cbDirectEvent")
        .Text("ComboBox1")
        .Store(store => store.Add(
               ...
            ))
            .Model(model => model.Add(Html.X().Model()
              .Fields(fields =>
              {
                  fields.Add(Html.X().ModelField().Name("Value"));
              })
            ))
          ))
        .DirectEvents(directEvents =>
        {
          directEvents.Select.Url = "/Controller/ValueSelect";
        })
        .DisplayField("Value")
        .ValueField("Value")
    )
    Controller Code

            
    public ActionResult ComboBoxSelect()
    {
      // Use selected value from combobox
    }
    Last edited by Daniil; Apr 20, 2012 at 6:55 PM. Reason: [CLOSED]
  2. #2
    Hi,

    The best way would be sent a value via ExtraParams.

    Example
    @(Html.X().ComboBox()
        .DirectEvents(directEvents => {
            directEvents.Select.Url = "Test/ComboBoxSelect";
            directEvents.Select.ExtraParams.Add(new Ext.Net.Parameter() 
                { 
                    Name="value", 
                    Value="record.get(this.valueField)", 
                    Mode = ParameterMode.Raw 
                });
        })
    )
    public ActionResult ComboBoxSelect(string value)
  3. #3

    Adiditonal queston about ExtraParams

    Thanks for the reply Daniil

    I've got another related question. Is it possible to access other component values when passing parameters (2nd ExtraParam block)

          .DirectEvents(directEvents =>
          {
              directEvents.Select.Url = "/Shared/ComboBoxSelect";
              directEvents.Select.ExtraParams.Add(new Parameter()
              {
                  Name = "parameter1",
                  Value = "item.value",
                  Mode = ParameterMode.Raw
              });
             directEvents.Select.ExtraParams.Add(new Parameter()
              {
                  Name = "parameter2",
                  Value = "document.getElementById('componentID').value",
                  Mode = ParameterMode.Raw
              });     
          })
  4. #4
    Please wrap the code in [CODE ] tags. It will improve its readability.
  5. #5
    Thanks for editing.

    This doesn't allow to access Ext.NET widgets.
    document.getElementById('componentID')
    You can access Ext.NET widgets directly by its client ids.

    Example
    Value = "App.componentID.getValue()"

Similar Threads

  1. [CLOSED] Passing function result as value of a parameter
    By RCN in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 13, 2012, 11:43 AM
  2. Replies: 0
    Last Post: Jan 26, 2011, 8:38 AM
  3. Replies: 5
    Last Post: Dec 07, 2010, 5:06 PM
  4. Passing parameter to Ajax Method
    By shijith in forum 1.x Help
    Replies: 1
    Last Post: Jul 26, 2010, 12:52 PM
  5. [CLOSED] [1.0] passing Extra Parameter to button Click from client-side
    By webclouder in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Jun 07, 2010, 12:36 PM

Tags for this Thread

Posting Permissions