Save Silverlight DataGrid sort - sorting

I have a Silverlight 2.0 DataGrid that contains a list of items that needs to be refreshed in an interval to display the up-to-the-minute information. There are items in this grid that may be added and may be removed while the screen is being displayed to the current user. For Example:
If grid looks like the following, then after a minute the data needs to be refreshed because another user has added a 4th entry. (notice the sort is assending by Last Name)
Data Grid http://img16.imageshack.us/img16/1667/datagrid.jpg
Then when I get the new data set and set it to the datagrid's DataSource property, it resorts the array based on my first column like so:
Data Grid2 http://img19.imageshack.us/img19/1294/datagridb.jpg
Is there any way to reapply the sort after the data source has been updated? I'd like to save the fact that the data grid is sorted by last name, then update the data source, and then reapply the sort to the data grid. So, in the end the datagrid would look like the following:
Data Grid3 http://img13.imageshack.us/img13/4636/datagrid2.jpg
These screen shots are of course not a Silverlight data grid, but this is for simplicity in explaining the situation.

Probably the best way to go about it is to use PagedCollectionViews, although I have not tested this out myself, these classes contain a property that stores the different sorting methods applied to them. I believe that you can probably grab the current sorting element from one collection, connect to the new collection, and apply the sorting to the new collection.
For a more in depth discussion on how this all works, you can follow the explanation here

I tried using PagedCollectionViews as well as CollectionViewSources (I used the new collection to overwrite the existing source collection).
My solution isn't the most elegant, but it works. When updating the source of the DataGrid I did my own change detection.
In other words, instead of blindly overwriting the source collection I iterated through the new collection, compared each item to the existing collection, and updated the existing items where possible.
Hope that helps.

After researching how to do this, I have figured it out. I tried to implement what the others said to try, but could not get it to work in Silverlight 2.0. Thus, I searched StackOverflow and Google for more answers. ScottLogic and CodeProject seemed to be what I was looking for but I couldn't get them to work fully. So with a bit of frustration and playing around with code, I finally arrived on the solution.
If the collection that you're using for your DataGrid's ItemsSource is ObservableCollection(Of T), you can get the ability of sorting for the object, plus you can update the collection dynamically at runtime, causing the grid to refresh with the item you insert. I've created a Google Code project that is GPL for you to checkout and download. Please note that I'm using the Microsoft Silverlight 2.0 DataGrid December 2008 Release for this project. I have linked to this download on the project page as well. (The dll's required are referenced from within a lib folder inside the project).
Enjoy!
Silverlight 2.0 DataGrid Sort Project on Google Code

Related

Dynamic content display

when I select (say customer) using Dropdown I would want to show users all the properties on a side table or division. Essentially, displaying the selected customer's fields on the same page for the users to verify/read.
I am using laravel-backpack for development and finding it difficult to implement. Any help is greatly appreciated.
I'm afraid there's no existing way to achieve that, you'd have to code it.
But you don't have to start from scratch, you can use the code for the select2 field (or whatever field you prefer) and create a new field type, say select2_and_preview by tweaking the Javascript inside that one file.
There's recently been a Feature Request for a similar feature (see here), you might want to pitch in with your opinion if you want it created by the team, and included in the official build.

Sort by clicking on column not displaying

I'm trying to turn on the sort feature on one of my grids. I've cloned the examples in the Kendo doc, but it never becomes available.
Does it have to be set before or after filters and/or columns? I found when modifying the filters, it had to be done before setting the columns, otherwise it would go with the default.
Thanks
As per usual, I post a question, and thirty seconds later I found the answer.
The developer who wrote the original code broke everything into functions, and then built the kendo portion from them. He never added the sortable option to the final build!

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

extjs 4 How to change ordering of shown column dropdown on grid

Using extjs 4.1.1
I have a grid with lots of columns >20.
Initially, most of these columns are hidden.
If a user wants to unhide the column, they select the menu on any column, then select the "columns" choice, this expands another dropdown/dropout which shows all of the columns. Those with checkboxes next to them are shown.
My issue is this:
The columns in the dropdown are shown in the order in which they are defined/displayed in the grid. The order in which they are displayed in the grid has been chosen for a good reason( e.g. id as the first column). However, when a user wants to display one of the hidden columns, it is hard for them to find it in the list. This is because the list is sorted in the order the columns are defined. I want to sort the column dropdown/dropout list in alphabetical order, without effecting the order of the columns in the grid.
How can this done?
I think I found the solution to your question.
First of all I don't have the Ext JS 4.1.1. framework on my current PC. So I tried to figure out you problem reading the Ext JS 4.1.3. documentation available on Sencha's site. But I don't think that they have made drastical changes in this part of the framework between the two minor releases so my solution should work in your case too.
I have tried out my solution using JSFiddle. Unfortunately they did not have the 4.1.1. ext-all.css file, so I have linked manually the 4.0.2 file available at Sencha, so the menu is looking a bit missplaced.
The header menu and it's submenus are managed by the Ext.grid.header.Container class. The column submenu is constructed by the getColumnMenu method. The whole menu is purged and reconstructed on every drag and drop or other event which should affect the grid view. As a result it is enough to overwrite this method in order to solve the problem. Because the headercontainer class is too deep in the framework it is hard to extend it, so you have to make use of the Ext.base.override method.
The column submenu's menu items are created from the result of the
items = headerContainer.query('>gridcolumn[hideable]')
query. So you have to first sort alphabetically the result, before creating the menu items. I have added to the class the sortColumns method which does all the sorting stuff.
So here is what I did: link to my solution.
I hope that this is what you were looking for.

How to insert multiple rows into embedded view from a subform? Lotus Notes

I have a section that contains a subform ( containing 3 editable fields for the user ).
Then I have an embedded view categorized having two actions: Add and Trash.
What i want to do: After the user complete the 3 fields and then press Add, the first row in the embedded view will appear. ( This easy thing I did ). But then after the first click on Add, I want that all the 3 fields to be refreshed, all of them to have as their value: "".
After, if the user wants to add another row into the embedded view (with different values), in my case it is overwrited on the 1st row. I want to be separate rows in order.
I tried something with #Command(ViewRefreshFields) into the Add action code but I didn't make it to work. Please help, J. U.
Jazir, I'm guessing that you also go by the names "Florin G Mihalache", "Josh Mitchell" and "Yveniss Ltoreau", and I've been following the development of your application along with many other professional Notes developers.
I really think you need to go back to the very first basics, and work out the difference between forms, subforms, documents, views, embedded views, and other important components of Lotus Notes databases.
I strongly suspect that for a couple of weeks you have been trying to use a form to create other documents, via a subform, to be displayed in an embedded view in that form, when what you should be using is just a view, and documents. Perhaps you might need to use pages, outlines and framesets. It is very important that you understand these basic concepts before confusing the people who have tried to help you, to whom you may have lied.
I have voted your question down, not just because you have shown a lack of research, but because you appear to keep switching ID when people lose patience with you. I will undo that vote if I become convinced that you are not Florin.
The documents displayed in an embedded view are controlled by the view's selection formula. You haven't shown that. You haven't shown your code in the Add button. You haven't shown what properties you have set on the embedded view -- e.g., show single category. So you're not giving us quite enough info to diagnose your problem and help you.
But in general, I think that if you want to control the order of insertion of individual documents into an embedded list, perhaps using an embedded folder would be a better idea than an embedded view.

Resources