Update a controls viewstate on an AJAX callback - ajax

I update a rad combo control using telerik calllback method described here
The items in the list are changed on the callback and I want to maintain this filtered list after the postback.
Is it possible to update the viewstate in the server side method? I think if I can access this i can then update both my list of items on the client and the server.. allow my drop down list to survive a postback
Any help appreciated

littleschris, you do not need to update the combobox viewstate but rather to store it selected value and then recover it after postback. Hope my explanation is useful.
Dick

Related

CRM 2013/2015/2016 subgrid popout, retain fetchxml query

I have a subgrid on my form which I assign a dynamically generated fetchxml query using javascript. When the user clicks on the subgrid's "pop out" button, the query is lost and it displays the default view for that entity.
The user needs to be able to perform multi selection and bulk editing. As far as I know this is not possible for subgrids in CRM 2013 upwards. Is there a way to retain the query when it is popped out?
There's no supported way to interact with a popped out grid. If you started digging into the client side application code, you might be able to find a hook to the new window, but doing so would be unsupported, liable to break, and I wouldn't recommend it.
I was going to suggest hiding that pop-out button on your entity's sub-grid altogether before re-reading that your users need to use the popped out grid for bulk edit.
In that case your best option will be to do ditch the JS and move to a RetrieveMultiple plugin against the sub-entity. RetrieveMultiple plugins should be generally avoided, but from what it sounds like in your case, it's your only option.
And, just to be thorough, are you positive you need dynamic fetch for the sub-grid? Is there any way you could come up with a view that would get close enough to your requirement, even if it's not perfect?
Update:
Based on the additional information you provided in your comment, I can only think of two options:
Implement a custom grid--or modify one of the free ones out there--that allows multi-select and bulk edit
Your custom web app takes the user's criteria, creates a personal view (entity: userquery) for the user and saves it to the database, then your JS on the form sets the grid to that view.
You can do that liks this:
document.getElementById("someGridId").control.SetParameter("viewtype", "4230"); // 4230 is the objecttypecode for userquery
document.getElementById("someGridId").control.SetParameter("viewid", "{11310965-0306-E611-80E5-3863BB36DD08}");
Doing this actually does make the popped out grid load the personal view, but in my tests just now the grid gets upset if you try to refresh it.
This approach has obvious downsides: 1) You have to come up with a way to clean up the personal views that get generated 2) the grid might break on refresh 3) it's unsupported and liable to break on an update.
Still worth considering, I suppose.
A more supported way instead of using unsupported getElementById is to hook a plugin to multiple retrieve of the entity and amend the query in there
Chris

radtooltipmanager add targetControl using ajax

I have a radtooltipmanager that have their target control inside datalist. This datalist is bound on the server side using ajax. I set the target control from itemdatabound event of datalist, but tooltip doesn't work.
Any help please.
If you are using AJAX to initially bind the list (i.e., it does not happen on the initial load, but during a subsequent partial postback), make sure that you include the RadToolTipManager in the partial update, because otherwise its new targets will not travel to the client.

jquery serialize returning incorrect values after previous async page update

Let me try and explain the scenario:
I have a form with multiple items in it. The form is multi-functional so it has multiple submit buttons that are handled on the server correctly.
A single item can be deleted (one submit button per item) and also all items can be saved (a submit button at the bottom of the form).
When an item is deleted a $.post is used and the DIV containing the form is updated with the new response using
$("#containingDIV").html(response)
therefore omitting the deleted item creating a new form.
If I subsequently hit the Save All button and call to
$(form).serialize();
serializes the correct number of items but it includes the item that was deleted and misses the last item in the form.
I can't get my head around why this is happening but I'm no jQuery guru so hoping someone can shed some light on this.
Any help is much appreciated.
Thanks,
Tom.
Thanks everyone for helping. I've just worked out what is going on and it's to do with ASP.NET MVC framework not jQuery. I inspected the response being returned and noticed that all the inputs contained the same item id's as they did prior to the delete. a call to ModelState.Clear() solved the problem for me. Arrrgghh! :D

Maintain SelectList Options over postbacks

I was wondering if there is a way to maintain your list of options on a Select List in MVC 3. I am pretty new to MVC but in WebForms you could populate the DropDownList on the first load of the page and then the ViewState would maintain that list for all of the AutoPostBacks. This was nice because often, DropDownLists are populated by query to the database. I know that ViewState does not exist in MVC but is there a better way of repopulating the SelectList without having to hit the database during the request of every post?
You have several options here.
Your selected value will be posted back. With that in mind since you no longer have ViewState you ideally want to
Have your Repository (if you dont have one - create one. You simply ask the repository for the data and it controls the caching or loading) that you ask for the data in the drop down, cache the data and just simply request it again. Rebind your list (use DropDownFor)
Use MVCContrib's Html.Serialize to essentially ViewState it, however the cache is a bit cleaner and doesnt rely on data sent back and forth.
Also remember that after you post your data, if everything is 'good' you want to REDIRECT back to your "GET" action to reload the data and display to the client. This was an issue in web forms that sometime a user saw XYZ after postback but after a refresh saw YXX. Using the PRG pattern in MVC posts-redirects-gets to load up fresh data.
After your post you should generally only redisplay the data if there was a validation error, otherwise redirect to a get method.
Your controller receives the value on postback. You have to place that value back in the model to tell the view what the selected value is.

Telerik RadCombobox not keeping state when using client side requestItems() to load

I'm using the Telerik RadComboBox control. I have two related combos and when the user selects a value in the first one I filter the second one.
I use the code below to achieve this:
localeCombo = $find("<%= ddlLocale.ClientID %>");
localeCombo.requestItems(item.get_value(), false);
This works totally fine, but when I do a postback my filtered combo resets to the original non filtered list, although all other controls retain their state. I assume this is because the server side list of items is not being updated when I use the client side callback requestItems() function.
Is this the case? Is there a simple way around this?
Any help would be much appreciated!
Thanks
Chris
Yep, most probably your suggestion is true. You may try keeping the second filtered combo value in session or cache storage and then restore it from there on postback - at least this is what I would do.
This is a bug with RadComboBox. I opened a ticket.

Resources