We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

ejGrid: menu filter -> Filter value preview ignores additional parameters

Thread ID:

Created:

Updated:

Platform:

Replies:

124847 Jul 4,2016 07:44 AM Apr 19,2017 11:25 AM JavaScript 5
loading
Tags: ejGrid
Florian Mihalits
Asked On July 4, 2016 07:44 AM

Hello.

I´m using a grid and additional query parameters.
I.e.:
var query = new ej.Query().addParams("mode", $("#jsMode").val());
self.grid = $("#gridJobs").ejGrid({
    dataSource: self.dataManager,
    query: query,
...

Filtering itself works pretty well. But if you enter a value and the grid is trying to display the preview values, the request is being made without the additionally defined parameters (like "mode" in my example). The request fails, because my controller needs a "mode" parameter.
How can I add additional parameters to the "value preview" request made by filtering?


Thank you and all the best,
Florian



Jayaprakash Kamaraj [Syncfusion]
Replied On July 5, 2016 08:12 AM

Hi Florian, 

Thank you for contacting Syncfusion support.   
  
We are unclear about your actual requirement, please share the following information to serve you better  

1.       Essential studio version details.   
2.       Browser version details.   
3.       Type of additional parameter “mode” (integer or string).   
4.       In your query, we could see that you have mentioned about “preview values". Please let us know what you actually mean? Please explain clearly.   
5.       Are you using any adaptors for data binding in Grid? If so, please mention the adaptor type.   
6.       Server side code example where you have obtained the additional parameter value.   
7.       In which scenario you are getting null value in additional parameter. Please explain the clear replication procedure or scenario.   
8.       Attach screenshot of the POST request in Network tab of browser developer tool. Please expand the post request and share the screenshot.   

Regards, 

Jayaprakash K. 


Malcolm van Staden
Replied On April 12, 2017 09:54 AM

Hi,

We are experiencing the same problem. When using the menu filter type: .FilterSettings(filter => { filter.FilterType(FilterType.Menu); }) the additional parameter is not included in the POST.

To answer your questions:

1.       Essential studio version details.
SyncFusion JavaScript V15.1.0.33 
2.    Browser version details.
Chrome 
Version 57.0.2987.133 (64-bit)
3.       Type of additional parameter “mode” (integer or string). 
Integer 
4.       In your query, we could see that you have mentioned about “preview values". Please let us know what you actually mean? Please explain clearly.
Preview values are the values that are shown in the autocomplete search suggestions - see attached image "preview_values.png"
5.       Are you using any adaptors for data binding in Grid? If so, please mention the adaptor type. 
URL adaptor - specifically:

                    .Datasource(ds => ds.URL("DataSource")
                        .Adaptor(AdaptorType.UrlAdaptor)
                        .InsertURL("Add")
                        .UpdateURL("Update"))
                    .Query("ej.Query().addParams('selectedGroup','0')")
  
6.       Server side code example where you have obtained the additional parameter value.   
        
public ActionResult DataSource(DataManager dm, int selectedGroup)
        {
            var users = new List<User>();
            var readResult = _userRepository.List(new RepositoryListing { ByUserId = GetUserId(), IncludeInactive = true });

            if (selectedGroup > 0)
                users = readResult.Results.Where(user => (user.AccessGroupMemberships & selectedGroup) != 0).ToList();
            else
                users = readResult.Results;

            var operation = new DataOperations();
            var operationResult = operation.Execute(users, dm);

            return Json(new DataResult { result = operationResult, count = users.Count }, JsonRequestBehavior.AllowGet);
        }

7.       In which scenario you are getting null value in additional parameter. Please explain the clear replication procedure or scenario.
When trying to apply a filter to one of the columns and entering a value for it to filter by, this is when the problem occurs
. This isn't a problem when the filter type is FilterBar.
8.       Attach screenshot of the POST request in Network tab of browser developer tool. Please expand the post request and share the screenshot. 
See attached screenshot "post_values.png" 

See also - "post_values_Bar.png" to see what happens when the filter type is changed to be FilterBar.

We tried the suggestion listed in this post: https://www.syncfusion.com/forums/123704/filtering-sorting-searching-not-working-if-grid-is-configured-with-datamanager-and-urladaptor
But "begin" is not called when the filtering takes place.

Kind Regards,
-Malcolm

Attachment: screen_shots_d69a41e8.zip

Jayaprakash Kamaraj [Syncfusion]
Replied On April 13, 2017 08:11 AM

Hi Malcolm, 

We understood from your query, you need to pass the addParams when fetch the data from server for ejAutocomplete in filter dialog and achieved this requirement by using DataBound event of ejGrid.  In this event,  we have bound the open event for ejDialog control and we have set the additional parameters by using  model.query of ejAutoComplete inside the open event of ejDialog. Please refer to the below help documents, code example and sample. 
                            
Help document for, 




@(Html.EJ().Grid<object>("Grid") 
   .Datasource(d => d.URL("/Home/DataSource").UpdateURL("/Home/CellEditUpdate").InsertURL("/Home/CellEditInsert").RemoveURL("/Home/CellEditDelete").Adaptor(AdaptorType.UrlAdaptor)) 
       .EnableAltRow() 
        .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing().EditMode(EditMode.Dialog); }) 
        .AllowPaging() 
        .Query("ej.Query().addParams('selectedGroup','0')") 
        .AllowFiltering() 
        .FilterSettings(fil=>fil.FilterType(FilterType.Menu)) 
        .. 
 
       .Columns(col => 
        { 
            col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).ValidationRules(v => v.AddRule("required", true).AddRule("number", true)).Width(90).Add(); 
            col.Field("CustomerID").HeaderText("Customer ID").Width(90).ValidationRules(v => v.AddRule("required", true).AddRule("minlength", 3)).Add(); 
            col.Field("Freight").HeaderText("Freight").TextAlign(TextAlign.Right).Width(75).EditType(EditingType.Numeric).Format("{0:C}").NumericEditOptions(new EditorProperties() { DecimalPlaces = 2 }).ValidationRules(v => v.AddRule("range", "[0,1000]")).Add(); 
            col.Field("ShipCity").HeaderText("Ship City").Width(90).Add(); 
        }) 
        .ClientSideEvents(eve => { eve.ActionBegin("begin").DataBound("databound").EndEdit("endEdit").EndAdd("endEdit"); }) 
) 
<script type="text/javascript"> 
    function databound(args) { 
        this.element.on("mousedown", ".e-gridheader .e-filtericon", function () { 
            $("#Grid_stringDlg").ejDialog({ 
                //open event of the filter menu dialog 
                open: function (e) { 
      
                    var dp = this.element.find(".e-autocomplete"), instance; 
                    var query = ej.Query().addParams('selectedGroup', '0'); 
                    if (dp.length) { 
                        instance = dp.data("ejAutocomplete"); 
                        instance.model.query = query; 
                    } 
                } 
            }); 
        }); 
 
    } 
</script> 


Regards, 

Jayaprakash K. 
 


Malcolm van Staden
Replied On April 18, 2017 06:19 AM

Hi,

Thank you - that is a workable solution albeit a hacky one (I don't see why the different filter types should behave differently).

Kind Regards,
-Malcolm

Jayaprakash Kamaraj [Syncfusion]
Replied On April 19, 2017 11:25 AM

Hi Malcolm, 
We have logged a feature request “Need to pass additional parameter while filtering the string column in Filtermenu ” and it can be implemented in any of our upcoming release. 

Regards, 

Jayaprakash K. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;