1

Right now i have a jqgrid with 3 columns as dropdown lists and some other columns as normal text.

I was inspired by this jqGrid toolbar search with autocomplete using json data and wanted to try to do instead of my dropdown lists an autocompletion textbox which retrive data same way as my dropodwns. I am trying to do this atm on a column with a textbox. The problem is when i am running the code and entering column with my autocompletion field i just gettion "loading..." it looks like i am not retriving data the right way..

code:

http://pastebin.com/95FUe8ys

UPDATE

Aditional info:

Column which i try to make autocompleetable is named EanNummer

{ name: 'EanNummer', index: 'EanNummer', width: 65, sortable: true, editable: true },

my action have to happend on load which looks like this:

loadComplete: function () {

              if (grid.getGridParam('datatype') === 'json') {
                  // build the set 'source' parameter of the autocomplete
                  grid.jqGrid('setColProp', 'EanNummer', {
                      searchoptions: {
                          sopt: ['bw'],
                          dataInit: function (elem) {
                              $(elem).autocomplete({
                                  source: '@Url.Action("GetCustumer3")',
                                  delay: 0,
                                  minLength: 0
                              });
                          }
                      }
                  });

              }

              jQuery("#list").trigger("reloadGrid", { stringResult: true, searchOnEnter: true, defaultSearch: "cn" }); // Call to fix client-side sorting

          },

where '@Url.Action("GetCustumer3")' at source is a method in controller which looks like this:

    public JsonResult GetCustumer3()
    {
        string vendorId = "";
        var username = "";
        var name = System.Web.HttpContext.Current.User.Identity.Name;
        var charArray = name.Split("\\".ToCharArray());
        username = charArray.Last();
        vendorId = service.GetVendorIdByUsername(username);

        var list = new List<string>();
        var customcat1 = service.GetAllIntCustomCategory1(vendorId);
        foreach (var custom1 in customcat1)
        {
            if (custom1.SortOrderId == 0)
                custom1.CustomName = "";
            list.Add(custom1.CustomName);
        }

        return Json(list);
    }

i am returning a list of strings as a jsonresult to source, but can jqgrid find out to do it that way??

Community
  • 1
  • 1
Timsen
  • 4,066
  • 10
  • 59
  • 117

0 Answers0