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
Can anyone help?
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:
- https://demos.telerik.com/aspnet-ajax/multiselect/overview/defaultcs.aspx
- https://demos.telerik.com/aspnet-ajax/multiselect/virtualization/defaultcs.aspx
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/.
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";
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.
Another test.
Same code in production, but with inproc session.
Do you have any idea?
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
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...
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
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.
- https://docs.telerik.com/kendo-ui/controls/editors/multiselect/virtualization
- Enabling the paging and setting the pageSize of the MultiSelect is efficient only when these features are used with virtualization.
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/.
Hi,
How do I make the particular items in radmultiselect list box disabled?
Please reply, thanks
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:
- https://feedback.telerik.com/kendo-jquery-ui/1358844-option-to-disable-multiselect-items
- https://docs.telerik.com/kendo-ui/knowledge-base/disable-multiselect-items
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/.