This is a migrated thread and some comments may be shown as answers.

Problem with radmultiselect and redis

11 Answers 418 Views
MultiSelect
This is a migrated thread and some comments may be shown as answers.
Fabio PM
Top achievements
Rank 1
Iron
Fabio PM asked on 05 Oct 2020, 11:05 AM
Hi

I'm a few days trying to solve a strange behavior with radmultiselect, but without success.

I have a page works fine for very years, but now I added a new control, the radmultiselect. When I use in production Redis with distributed session/cache provider, the page crash. Many strange behaviors occurs. When I use inproc, everything works fine. 

I added the radmultiselect dinamicaly like this example:

Telerik.Web.UI.RadMultiSelect rms;
rms = new RadMultiSelect();
rms.ID = "xyz";
rms.DataTextField = "text";
rms.DataValueField = "value";
rms.Filter = RadMultiSelectFilter.Contains;
rms.MinLength = 3;
rms.Font.Size = FontUnit.Small;
rms.Width = Unit.Percentage(70);
rms.AutoBind = false;
rms.AutoPostBack = true;
rms.WebServiceClientDataSource.PageSize = 20;
rms.WebServiceClientDataSource.AutoSync = true;
rms.WebServiceClientDataSource.AllowPaging = true;
rms.WebServiceClientDataSource.EnableServerPaging = true;
rms.WebServiceClientDataSource.EnableServerFiltering = true;
rms.WebServiceClientDataSource.EnableViewState = true;
rms.WebServiceClientDataSource.WebServiceSettings.Select.DataType = ClientDataSourceDataType.JSON;
rms.WebServiceClientDataSource.WebServiceSettings.Select.ContentType = "JSON";
rms.WebServiceClientDataSource.WebServiceSettings.Select.Url = f.FixupUrl("~/dal/webservices/service.asmx/getTags");
rms.Enable = true;
"name of placeholder".Controls.Add(rms);


The problem occurs when I try to add the database value.

I tried some formats:

1 - Dynamic list

List<dynamic> selected = new List<dynamic>();
 
foreach (DataRow dr_rms in dt_rms.Rows) {
    MultiSelectItem msi = new MultiSelectItem();
    msi.Value = dr_rms["value"].ToString();
    msi.Text = dr_rms["text"].ToString();
 
    rms.Items.Add(msi);
 
    var item = new {
        text = dr_rms["text"].ToString(),
        value = dr_rms["value"].ToString()
    };
    selected.Add(item);
}
 
rms.Value = selected;


2 - Fixed Class

public class RadMultiSelectClass {
    public int value { get; set; }
    public string text { get; set; }
}
 
List<RadMultiSelectClass> selected = new List<RadMultiSelectClass>();
 
foreach (DataRow dr_rms in dt_rms.Rows) {
    selected.Add(new RadMultiSelectClass { value = Convert.ToInt32(dr_rms["value"].ToString()), text = dr_rms["text"].ToString() });
}
 
rms.Value = selected;

webconfig:

Everything works fine: 
The radmultiselect get the value from database and the page flow are totaly normaly. With many postbacks, everything works fine.
<sessionState mode="InProc" cookieless="false" timeout="120" />


Page with strange behaviors, loosing sessions.
<sessionState mode="Custom" customProvider="MySessionStateStore">
  <providers>
<add name="MySessionStateStore" type="Microsoft.Web.Redis.RedisSessionStateProvider" host="xxx.cache.amazonaws.com" port="6379" accessKey="" ssl="false" retryTimeoutInMilliseconds="60" throwOnError="false" />
  </providers>
</sessionState>

If I comment the "// rms.Value = selected;" The page works fine, with or without redis. The problem only occurs when I put some value to rms.value.

The RadMultiSelect.Value have any problem with Redis or distributed session provider?

 

Thanks

11 Answers, 1 is accepted

Sort by
0
Fabio PM
Top achievements
Rank 1
Iron
answered on 07 Oct 2020, 01:00 PM

Can anyone help?

0
Peter Milchev
Telerik team
answered on 08 Oct 2020, 11:10 AM

Hello Fabio,

The .Value property is an array of objects representing only the value of the item. 

Please try setting the Value as an array containing only the values you have, not whole objects, just as demonstrated here:

RequiredMultiSelect.Value = new[] { "Anne King", "Andrew Fuller" };

Regards,
Peter Milchev
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Fabio PM
Top achievements
Rank 1
Iron
answered on 08 Oct 2020, 12:05 PM

Hi Peter

Thank you for your reply.

Tests results:

Value (id)

RadMultiSelect.Value = new[] { "1", "2" };

 

Result: normal page flow (with Redis or inproc) but not show the selected items (same behavior inredis or inproc environment).

Text

RadMultiSelect.Value = new[] { "Tag 1", "Tag 2" };

Result: same result as above.

List + Object (ienumerable)

List<dynamic> selected = new List<dynamic>();
object item = new {
    text = dr_rms["text"].ToString(),
    value = dr_rms["value"].ToString()
};
selected.Add(item);
RadMultiSelect.Value = selected.AsEnumerable();

Result: with inproc session (web.config) everything works fine (page flow and selected items). But in Redis environment (production with many servers and load balancer) the page flow crash, but, the selected items are showed.

How can I use this format "new[] { "Anne King", "Andrew Fuller" };" if the value or text has dynamic names?

RadMultiSelect.DataTextField = "text";
RadMultiSelect.DataValueField = "value";

 

0
Fabio PM
Top achievements
Rank 1
Iron
answered on 08 Oct 2020, 12:38 PM

Hi Petter

The behavior are realy realy strange.

I attached two codes. The first are in localhost with inproc. The second in production with redis.

Same code in both.

0
Fabio PM
Top achievements
Rank 1
Iron
answered on 08 Oct 2020, 12:42 PM

Another test.

Same code in production, but with inproc session.

Do you have any idea?

0
Fabio PM
Top achievements
Rank 1
Iron
answered on 08 Oct 2020, 01:05 PM

Another post.

One problem solved!

I dont know why, but with "RadMultSelect.RenderMode = RenderMode.Lightweight" and "RadMultiSelect.Value = new[] { "1", "2" };" and "RadMultiSelect.AutoBind = true";

All works fine with Redis.

Second problem...

My dataservice has a server pagination = "RadMultiSelect.WebServiceClientDataSource.PageSize = 20".

How can I get the value if the index of the value is 21 or 100 or 200?

Thanks

0
Fabio PM
Top achievements
Rank 1
Iron
answered on 08 Oct 2020, 02:26 PM

Final question...

See the attached file.

When autobind = true I cant add manual multiselectitem. And the webservice only pass the first 20 results, but I need the id 61 and 97... I cannot increase the page size because the origin table has tousands of rows...

Disappointed with this component...

0
Fabio PM
Top achievements
Rank 1
Iron
answered on 08 Oct 2020, 06:25 PM

Hi Peter

Final solution. But I'm not happy...

Telerik.Web.UI.RadMultiSelect rms;
 
rms = new RadMultiSelect();
rms.ID = name;
rms.DataTextField = "text";
rms.DataValueField = "value";
rms.Filter = RadMultiSelectFilter.Contains;
rms.MinLength = 3;
rms.Font.Size = FontUnit.Small;
rms.Width = Unit.Percentage(70);
rms.AutoBind = true;
rms.AutoPostBack = true;
rms.EnableEmbeddedScripts = true;
rms.RegisterWithScriptManager = true;
rms.RenderMode = RenderMode.Native;
rms.WebServiceClientDataSource.PageSize = 20;
rms.WebServiceClientDataSource.AutoSync = true;
rms.WebServiceClientDataSource.AllowPaging = true;
rms.WebServiceClientDataSource.EnableServerPaging = true;
rms.WebServiceClientDataSource.EnableServerFiltering = true;
rms.WebServiceClientDataSource.EnableViewState = true;
rms.WebServiceClientDataSource.ViewStateMode = ViewStateMode.Enabled;
rms.WebServiceClientDataSource.RegisterWithScriptManager = true;
rms.WebServiceClientDataSource.WebServiceSettings.Select.DataType = ClientDataSourceDataType.JSON;
rms.WebServiceClientDataSource.WebServiceSettings.Select.ContentType = "JSON";
rms.WebServiceClientDataSource.WebServiceSettings.Select.Url = f.FixupUrl("~/webservices/service.asmx/getTags");
rms.Enable = Enabled;
 

Datatable dt_rms = null; (get data from sql in any way you want)...

string[] aSelected = new string[dt_rms.Rows.Count];
string user_data = "";
int count = 0;
 
foreach (DataRow dr_rms in dt_rms.Rows) {
    if (user_data != "") {
        user_data += ",";
    }
    user_data += dr_rms["value"].ToString();
 
    aSelected[count] = dr_rms["value"].ToString();
 
    count ++;
}
 
rms.Value = aSelected;
 
var filter1 = new ClientDataSourceFilterExpression{ LogicOperator= ClientDataSourceFilterLogicOperator.And};
filter1.Filters.Add(new ClientDataSourceFilterEntry { FieldName = "xxx", Operator = ClientDataSourceFilterOperator.EqualTo, Value = user_data });
rms.WebServiceClientDataSource.FilterExpression.Filters.Add(filter1);

 

With "filter1" I can select the user data from database in the webservice.

The webservice receive the filter value on querystring param "filter[filters][0][filters][0][value]".

The only problem is the delay to load the data because the component only receive the value after full page load.

Thanks

0
Peter Milchev
Telerik team
answered on 09 Oct 2020, 04:47 PM

Hello Fabio,

If you are limiting the number of records loaded, then the Server filtering will not be sufficient. In such a case, you would need the Virtualization feature, that will load the data in portions and only when needed. 

Then, you would be able to fire an additional ValueMapper request to the service that will retrieve only the items related to the values you send.

For your convenience, I have attached a sample project where the Virtualization demo is isolated and you can use it as a reference point.

Regards,
Peter Milchev
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Hari
Top achievements
Rank 1
answered on 12 Feb 2021, 09:22 AM

Hi,

How do I make the particular items in radmultiselect list box disabled?

Please reply, thanks

0
Peter Milchev
Telerik team
answered on 16 Feb 2021, 10:01 AM

Hello Hari,

In order to simulate a disabled item, you should cancel the OnSelect client-side event similar to the description for the Kendo UI MultiSelect that is used internally by the RadMultiSelect:

You can add more information to the items and based on that information to style the items differently and cancel the select event.

Regards,
Peter Milchev
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
MultiSelect
Asked by
Fabio PM
Top achievements
Rank 1
Iron
Answers by
Fabio PM
Top achievements
Rank 1
Iron
Peter Milchev
Telerik team
Hari
Top achievements
Rank 1
Share this question
or