Current filter:
                                You should refresh the page.
                                Support Center
                                0
                                  • Is there any way we can pass values to onComboBoxSelectedIndexChanged, other than s and e.


                                • Dear Vikas,
                                  I am afraid your requirements are unclear to me. Would you please clarify what task you wish to accomplish?

                                • VikasAgarwal84 12.21.2012

                                  I have a definition of a combobox like this

                                  @Html.DevExpress().ComboBox(
                                                      settings =>
                                                          {
                                                              settings.Name = "VariantCode";
                                                              settings.ControlStyle.CssClass = "dropdown";
                                                              settings.Properties.IncrementalFilteringMode = IncrementalFilteringMode.StartsWith;
                                                              settings.Properties.DropDownStyle = DropDownStyle.DropDownList;
                                                              settings.Properties.TextField = "Desc";
                                                              settings.Properties.ValueField = "Id";
                                                              settings.Properties.ValueType = typeof(int);
                                                              settings.Properties.ClientSideEvents.Init="OnComboInit";
                                                              settings.Properties.ClientSideEvents.GotFocus="OnComboGotFocus";
                                                              settings.Properties.ClientSideEvents.LostFocus="OnComboLostFocus";
                                                          }).BindList(Model.Variants).Bind(Model.VariantCode).GetHtml()

                                  and JS like this

                                  var nullTextArr = [["VariantCode", "Variant..."],
                                      ["Style", "Style..."],
                                  ["Timing", "Timing..."],
                                  ["CurrencyCode", "Currency..."],
                                  ["DivisorOrLevel", "DivisorOrLevel..."]];

                                  function OnComboLostFocus(s, e) {
                                      if (s.GetValue() !== "" && s.GetValue() != null)
                                          return;
                                      
                                      var input = s.GetInputElement();
                                      input.style.color = "gray";
                                      input.value = FindNullValue(s.name);
                                  }

                                  function FindNullValue(colName) {
                                      for (var i=0;i<nullTextArr.length;i++)
                                      {
                                          if(nullTextArr[i][0] == colName) {
                                              return nullTextArr[i][1];
                                          }
                                      }
                                      return "";
                                  }

                                  function OnComboGotFocus(s, e) {
                                      var input = s.GetInputElement();
                                      if (input.value == FindNullValue(s.name)) {
                                          input.value = "";
                                          input.style.color = "black";
                                      }
                                  }

                                  function OnComboInit(s, e) {
                                      OnComboLostFocus(s, e);
                                  }

                                  So comboBox calls certain events like OnComboInit, OnComboGotFocus and OnComboLostFocus.

                                  Now Parameters are s and e, Is there any way we can pass more parameters to the function.

                                  This question is similar to my question but with a different approach, where Mike informed be about JsProperties:
                                  http://www.devexpress.com/Support/Center/Question/Details/Q453066

                                You must  log in  or  register  to leave comments

                                1 Solution

                                0

                                Hello Vikas,

                                Thank you for your clarification. I should say that your approach is not entirely correct. Let me clarify some points.

                                1. Our 's' and 'e' event parameters are similar to 'this' and 'event' parameters of standard JavaScript functions. As you probably know, JavaScript events take only two parameters. Our events work the same. It is impossible to send more parameters.

                                2. Against a JavaScript event, you can send any number of parameters to a JavaScript method. For example:

                                [JScript]
                                function OnComboInit(s, e) { CallSomeMethod(s, e, s.GetInputElement()); }

                                Based on these notes, your code should be as follows:

                                [JScript]
                                function OnComboGotFocus(s, e) { CallSomeMethod(s, e, s.GetInputElement()); } function OnComboInit(s, e) { CallSomeMethod(s, e, s.GetInputElement()); } function CallSomeMethod(s, e, input) { if (input.value == FindNullValue(s.name)) { input.value = ""; input.style.color = "black"; } }
                                • VikasAgarwal84 12.24.2012

                                  Thanks Marion for reply. I know that we can send parameters to a function but point was to send from control definition. Anyways I am using JsProperties (as the Mike's answer of my question)

                                • I am afraid from your response it is not quite clear whether or not the problem is resolved. If not, would you please clarify the issue you have encountered in greater detail? Your time and cooperation are highly appreciated.

                                • VikasAgarwal84 12.24.2012

                                  Thanks Marion. My Issue is resolved, This ticket was raised to know that if we can pass any other arguments along with s and e. As you said that is the nature of the event and DevEx also follow the same pattern, that We cannot pass any other parameter.

                                • Thank you for the update. If you have any other questions you are welcome to contact us at any time.

                                You must  log in  or  register  to leave comments

                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2014 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners