Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Change Search UI Column Default Selection
09/10/2013
14:41
Avatar
pommygranite
Member
Members
Forum Posts: 4
Member Since:
07/10/2013
sp_UserOfflineSmall Offline

When the search window is opened, there is a dropdown to select the column to search.  The order of the columns in the dropdown corresponds to the order of the columns in the grid.  This is fine, but the default selection is the first column.  99.9% of the time, my users will change the column dropdown to the 3rd column.  It would be more efficient if I could change the default dropdown selection to the 3rd column.  How can I do this? 

09/10/2013
17:21
Avatar
pommygranite
Member
Members
Forum Posts: 4
Member Since:
07/10/2013
sp_UserOfflineSmall Offline

Since there doesn't appear to be an easy way to change the default column listbox selection, i've implemented some convoluted code which does it:

    var change_search_now = false;
    // Change serach default from selection option to the one with value = '3'
    function changeSearchDefault(select){
      select.children("option:selected").removeAttr("selected");
      var newdefault = select.children("option[value='3']");
      newdefault.attr("selected", "selected");
      newdefault.trigger("change");
    }

And in the jqGrid navGrid initialization:
    onInitializeSearch: function(){
      change_search_now = true;
      changeSearchDefault($('.columns').children("select"));
      $("#fbox_grid_main_reset").click(function(){
        change_search_now = true;
      });
    },
    afterRedraw: function(){
      if (change_search_now){
        changeSearchDefault($('.columns').children("select"));
        change_search_now = false;
      }
      // Add "+" button click handlers to change search column default of newest search row item
      $("input[value='+']").each(function(inputindex){
        $(this).click(function(){
          $("input[value='+']").each(function(clickedindex){
            if (clickedindex == inputindex){
              // Change default
              changeSearchDefault($(this).closest('tr').siblings(":last").children(".columns").children("select"));
            }
          });
        });
      });
    },

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
56 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information