Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeGetting StartedGetting StartedNew to DNN Plat...New to DNN Plat...Want to customize jquery custom comboboxWant to customize jquery custom combobox
Previous
 
Next
New Post
6/13/2013 11:41 AM
 
  1. Want to customize jquery custom combobox
 

I Want to customize editability, width, font-size, font-family of jquery custom combobox

here i have applied width but it applied to all comboboxes same,but i want that each individual combobox width will adjust automatically equal to width of biggest text item in it and no extra space or no overflow of any text should happen ,but iam not able to do so

Also suggest me way to customize editability, font-size, font-family

Please help, below is my current code:

<style type="text/css">
  .custom-combobox {
    position: relative;
    display: inline-block;
      font: 14px arial !important;
  }
  .custom-combobox-toggle {
    position: absolute;
    top: 0;
    bottom: 0;
    margin-left: -1px;
    padding: 0;
    /* support: IE7 */
    *height: 1.2em;
    *top: 0.1em;
  }
  .custom-combobox-input {
    margin: 0;
    padding: 0.1em;
    width:5em;
    font: 14px arial !important;
}
  </style>
  <script type="text/javascript">
      (function ($) {
          $.widget("custom.combobox", {
              _create: function () {
                  this.wrapper = $("<span>")
          .addClass("custom-combobox")
          .insertAfter(this.element);

                  this.element.hide();
                  this._createAutocomplete();
                  this._createShowAllButton();
              },

              _createAutocomplete: function () {
                  var selected = this.element.children(":selected"),
          value = selected.val() ? selected.text() : "";

                  this.input = $("<input>")
          .appendTo(this.wrapper)
          .val(value)
          .attr("title", "")
          .addClass("custom-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left")
          .autocomplete({
              delay: 0,
              minLength: 0,
              source: $.proxy(this, "_source")
          })
          .tooltip({
              tooltipClass: "ui-state-highlight"
          });

                  this._on(this.input, {
                      autocompleteselect: function (event, ui) {
                          ui.item.option.selected = true;
                          this._trigger("select", event, {
                              item: ui.item.option
                          });
                      },

                      autocompletechange: "_removeIfInvalid"
                  });
              },

              _createShowAllButton: function () {
                  var input = this.input,
          wasOpen = false;

                  $("<a>")
          .attr("tabIndex", -1)
          .attr("title", "Show All Items")
          .tooltip()
          .appendTo(this.wrapper)
          .button({
              icons: {
                  primary: "ui-icon-triangle-1-s"
              },
              text: false
          })
          .removeClass("ui-corner-all")
          .addClass("custom-combobox-toggle ui-corner-right")
          .mousedown(function () {
              wasOpen = input.autocomplete("widget").is(":visible");
          })
          .click(function () {
              input.focus();

              // Close if already visible
              if (wasOpen) {
                  return;
              }

              // Pass empty string as value to search for, displaying all results
              input.autocomplete("search", "");
          });
              },

              _source: function (request, response) {
                  var matcher = new RegExp($.ui.autocomplete.escapeRegex(request.term), "i");
                  response(this.element.children("option").map(function () {
                      var text = $(this).text();
                      if (this.value && (!request.term || matcher.test(text)))
                          return {
                              label: text,
                              value: text,
                              option: this
                          };
                  }));
              },

              _removeIfInvalid: function (event, ui) {

                  // Selected an item, nothing to do
                  if (ui.item) {
                      return;
                  }

                  // Search for a match (case-insensitive)
                  var value = this.input.val(),
          valueLowerCase = value.toLowerCase(),
          valid = false;
                  this.element.children("option").each(function () {
                      if ($(this).text().toLowerCase() === valueLowerCase) {
                          this.selected = valid = true;
                          return false;
                      }
                  });

                  // Found a match, nothing to do
                  if (valid) {
                      return;
                  }

                  // Remove invalid value
                  this.input
          .val("")
          .attr("title", value + " didn't match any item")
          .tooltip("open");
                  this.element.val("");
                  this._delay(function () {
                      this.input.tooltip("close").attr("title", "");
                  }, 2500);
                  this.input.data("ui-autocomplete").term = "";
              },

              _destroy: function () {
                  this.wrapper.remove();
                  this.element.show();
              }
          });
      })(jQuery);

      $(function () {
          $("#ddlGRCode").combobox();
          $("#ddlFromCity").combobox();
          $("#ddlToCity").combobox();
          $("#ddlConsignorName").combobox();
          $("#ddlConsigneeName").combobox();
          $("#ddlFreightMode").combobox();
          $("#ddlAddCoCe").combobox();
      });
 
    
     


  </script>

 

 

 
New Post
6/15/2013 11:04 AM
 

Hello friends,

I got the way to customize jquery custom combobox by making changes in the bottom most function() as below, hope it will helpfull to other friends who want similar customization:

$(function () {

$("#ddlGRCode").combobox();
$("#ddlGRCode").parent().find("input.ui-autocomplete-input").css('background', 'white');

$("#ddlFromCity").combobox().parent().find("input.ui-autocomplete-input").css('width', '120px');
$("#ddlFromCity").parent().find("input.ui-autocomplete-input").css('background', 'white');
$("#ddlToCity").combobox().parent().find("input.ui-autocomplete-input").css('width', '120px');
$("#ddlToCity").parent().find("input.ui-autocomplete-input").css('background', 'white');

$("#ddlConsignorName").combobox().parent().find("input.ui-autocomplete-input").css('width', '120px');
$("#ddlConsignorName").parent().find("input.ui-autocomplete-input").css('background', 'white');

$("#ddlConsigneeName").combobox().parent().find("input.ui-autocomplete-input").css('width', '120px');
$("#ddlConsigneeName").parent().find("input.ui-autocomplete-input").css('background', 'white');

$("#ddlFreightMode").combobox().parent().find("input.ui-autocomplete-input").css('width', '120px');
$("#ddlFreightMode").parent().find("input.ui-autocomplete-input").css('background', 'white');

$("#ddlAddCoCe").combobox();
$("#ddlAddCoCe").parent().find("input.ui-autocomplete-input").css('background', 'white');

}); 

 

 

 
Previous
 
Next
HomeHomeGetting StartedGetting StartedNew to DNN Plat...New to DNN Plat...Want to customize jquery custom comboboxWant to customize jquery custom combobox


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out