Episerver sorting order of pages should not effect website pages sorting order - episerver

When i am sorting order of the pages in Episerver, its affecting the website also. means website pages are also changes sorting order.
how we can sort order of pages in episerver in a way that it should not affects website page sorting order.
Is there any configuration or settings in episerver?

Assuming you have a PageDataCollection you use the FilterSort class
Example
// your pages
PageDataCollection _newsPageItems;
FilterForVisitor.Filter(_newsPageItems);
new FilterSort(FilterSortOrder.PublishedDescending).Filter(_newsPageItems);
// The _newsPageItems are now filtered and sorted
This is the standard way of sorting and securing listed information from Episerver, also read the article Searching for pages based on page type
Considering you use the DataFactory to fetch a list with pages you can build a PageDataCollection from a Enumerable<PageData> object instance
Also using the DataFactory is bad practice and you should be using FilterForVisitor as well. My recommended implementation would be
// Construct an IContentLoader, this can also be done using Dependency Injection
var loader = ServiceLocator.Current.GetInstance<IContentLoader>();
// Get the children of your reference
var children = loader.GetChildren<PageData>(pageLink, LanguageSelector.AutoDetect(true));
// Construct new PageDataCollection and filter for visitor
var sortableChildren = EPiServer.Filters.FilterForVisitor.Filter(children);
// Sort
FilterSort sortFilter = new FilterSort(FilterSortOrder.CreatedDescending);
sortFilter.Sort(sortableChildren);

Related

SuiteCommerce Advanced - Show a custom record on the PDP

I am looking to create a feature whereby a User can download any available documents related to the item from a tab on the PDP.
So far I have created a custom record called Documentation (customrecord_documentation) containing the following fields:
Related item : custrecord_documentation_related_item
Type : custrecord_documentation_type
Document : custrecord_documentation_document
Description : custrecord_documentation_description
Related Item ID : custrecord_documentation_related_item_id
The functionality works fine on the backend of NetSuite where I can assign documents to an Inventory item. The stumbling block is trying to fetch the data to the front end of the SCA webstore.
Any help on the above would be much appreciated.
I've come at this a number of ways.
One way is to create a Suitelet that returns JSON of the document names and urls. The urls can be the real Netsuite urls or they can be the urls of your suitelet where you set up the suitelet to return the doc when accessed with action=doc&id=_docid_ query params.
Add a target <div id="relatedDocs"></div> to the item_details.tpl
In your ItemDetailsView's init_Plugins add
$.getJSON('app/site/hosting/scriptlet.nl...?action=availabledoc').
then(function(data){
var asHtml = format(data); //however you like
$("#relatedDocs").html(asHtml);
});
You can also go the whole module route. If you created a third party module DocsView then you would add DocsView as a child view to ItemDetailsView.
That's a little more involved so try the option above first to see if it fits your needs. The nice thing is you can just about ignore Backbone with this approach. You can make this a little more portable by using a service.ss instead of the suitelet. You can create your own ssp app for the function so you don't have to deal with SCAs url structure.
It's been a while, but you should be able to access the JSON data from within the related Backbone View class. From there, within the return context, output the value you're wanting to the PDP. Hopefully you're extending the original class and not overwriting / altering the core code :P.
The model associated with the PDP should hold all the JSON data you're looking for. Model.get('...') sort of syntax.
I'd recommend against Suitelets for this, as that's extra execution time, and is a bit slower.
I'm sure you know, but you need to set the documents to be available as public as well.
Hope this helps, thanks.

Sorting and Filtering a collection in a Paged ListBox

I have a database with 10,000 items, to which you can add and remove while the app is running.
I have a ListBox that displays at most 100 items, and supports paging.
You can filter and sort on the 10,000 items, which needs to be immediately reflected in the listbox.
I have a button that randomly selects an item as long as it passes the filters.
What is the best set of collections/views to use for this kind of operation?
So far, my first step will be to create an ObservableCollection of ALL items in the database which we will call MainOC.
Then create a List of all items that match the filter by parsing MainOC which we will call FilteredList.
Then create a ListCollectionView based on the above List that holds the first 100 items.
CONS:
You have to recreate the ListCollectionView every time a sort operation is applied.
You have to recreate the ListCollectionView every time you page.
You have to recreate the ListCollectionView every time a filter is changed.
You have to recreate the ListCollectionView every time an item is added or removed to MainOC.
Is there a better approach that I am missing?
For example, I see that you can apply filters to a ListCollectionView. Should I populate my ListCollectionView with all 10,000 items? But then how can I limit how many items my ListBox is displaying?
Should I be doing my filtering and sorting directly against the database? I could build FilteredList directly off the database and create my ListCollectionView based off that, but this still has all the cons listed above.
Looking for any input you can provide!
This is a problem which is easily solved using DynamicData . Dynamic data is based on rx so if you are not familiar with the wonderful Rx I suggest you start learning it. There is quite a bit of a learning curve but but the rewards are huge.
Anyway back to my answer, the starting point of dynamic data is to get some data into a cache which is constructed with a key as follows
var myCache = new SourceCache<MyObject, MyId>(myobject=>myobject.Id)
Obviously being a cache there are methods to add, update and remove so I will not show those here.
Dynamic data provides a load of extensions and some controllers to dynamically interrogate the data. For paging we need a few elements to solve this problem
//this is an extension of observable collection optimised for dynamic data
var collection = new ObservableCollectionExtended<MyObject>();
//these controllers enable dynamically changing filter, sort and page
var pageController = new PageController();
var filterController = new FilterController<T>();
var sortController = new SortController<T>();
Create a stream of data using these controllers and bind the result to the collection like this.
var mySubscription = myCache.Connect()
.Filter(filterController)
.Sort(sortController)
.Page(pageController)
.ObserveOnDispatcher() //ensure we are on the UI thread
.Bind(collection)
.Subscribe() //nothing happens until we subscribe.
At any time you can change the parameters of the controllers to filter, sort, page and bind the data like follows
//to change page
pageController.Change(new PageRequest(1,100));
//to change filter
filterController.Change(myobject=> //return a predicate);
//to change sort
sortController .Change( //return an IComparable<>);
And as if by magic the observable collection will self-maintain when any of the controller parameters change or when any of the data changes.
The only thing you now have to consider is the code you need for loading the database data into the cache.
In the near future I will create a working example of this functionality.
For more info on dynamic data see
Dynamic data on Github
Wpf demo app

MVC ExtJS 4, update a store record using record from other store

I have two stores:
FAQs - contains a lot of models of my items
FAQ - contains one model.
In view mode I work with FAQs (to see all items) and in edit mode I work with FAQ just to work with one item and not to load all of them.
After finishing editing and saving FAQ I need to find that item in FAQs and make changes there as I've made in FAQ. I don't use network for it.
I know two ways:
1) find needed record in FAQs and replace it there
_updateFaqsStore: function() {
var faqsStore = Ext.data.StoreManager.lookup("faqs.FAQs");
var activeRec = this.activeRecord;
var index = faqsStore.indexOf( faqsStore.findRecord('id',activeRec.get('id')) ); // index in faqsStore of activeRec
faqsStore.remove(faqsStore.findRecord('id',activeRec.get('id'))); // remove old rec
faqsStore.insert(index, activeRec); // insert new - activeRec
but the object structure is not the same (though I use the same model)
2) find needed record in FAQs and set there every field
var faqsItem = faqsStore.findRecord('id', activeRec.get('id')); // find same item in FAQs store
faqsItem.set("myField", activeRec.get('myField')); // make changes in FAQs as in FAQ
but I need to enumerate all fields.
Maybe, there is some other way out? Please, help me!
You should not use two stores in this case. Why aren't you just using one store FAQs ? You then select the record, and you edit it directly.
For your use case there is no need at all to use two stores.
Also, you say you need to minimize the number of requests to the server. There is no problem for this. Just edit all the records you need to, and the at the end, you save all to the server at once.
Look at this example : it shows how to edit a record in a separate form, how to configure your requests (autoSync and batch buttons). You will deactivate autoSync and use batches to minimize roundtrips to the server.
Look also at rowediting example. This allows you to edit the data even easier.

Access a collection from a different router/view

I'm still kind of new to Backbone, and I'm pretty stumped by this...
I have a router/collection/view for Titles, and a router/collection/view for Campaigns.
When a user creates a new campaign, it must be associated with a title. So in the create form, I need to access the list of all titles so I can get their names and (rails) IDs.
I'm not sure how to access this title list from within my Campaigns view though.
A few thoughts on solutions:
Using an association library like ligature -- this seems like a lot of work for a fairly straightforward problem, and I don't really need associations.. I just need the full list of titles.
Declaring my Titles collection in the global scope and passing it to the initializer of the Titles router.
Create a Titles collection in the Campaigns router.. this seems pretty redundant.
Happy to post code, but I don't know what is relavent.
If by global scope you mean window, I'd recommend avoiding that if possible. Do your Titles / Campaign classes have access to a shared scope? E.g.:
( function () {
var App = {};
// ...
// Titles code
var titles = App.titles = new Backbone.Collection;
// ...
// Campaign code
var titles = App.titles;
} )();
You might want to arrange things so the various parts of your app have access to a shared scope like that if you want to have a single Titles collection used throughout the app.
Otherwise if that's impractical or undesirable for some reason, you could just create a separate Titles collection in your Campaigns section and fetch it from the server, or bootstrap it, or however you want to populate it.
It's hard to be more specific without seeing some code, so maybe this will suggest some code that you think would be relevant to post.

Loading dropdownlists

what is the best way to load dropdown lists from reference/lookup tables for a desktop application?
the application is layed out into 3 tiers. I've built up my entities.
the front end has a form with 6 tabs. and one big save (another discussion :)
Should I load them all when the form is initially loaded? Are there any caching mechanisms I could use?
it is vb.net app on a network drive that is accessed by several users.
it's also worth noting that some reference tables may be updated. Via another form.
thanks
T
Lots of factors. One you need to populate in constructor so the data is there to populate the visual elements. Beware that just because a tab is not visible does not mean it is not loaded when you app starts.
For a static list of strings
public class Library : INotifyPropertyChanged
{
private List<string> dropDown1;
public List<string> DropDown1 { get { return dropDown1; } }
public Library()
{
// use data reader to populate dropDown1
}
}
I know this will get comments that can use something lighter than a List but List has a lot of nice features, easy syntax, and easy to populate. As a next step you could structure as a client server and use some static so the list is populated once and then shared by all. If you have more properties then substitute string with a class. For a dynamic list then in the get you grab the current data from the table on demand. In your get you could hold on to the last list and if the next request is within X seconds then return stale data. It depends on if stale data is acceptable.
There are many other approaches and I do not pretend this is the best. Just putting out a relatively simple example to get you started.
When it gets to hierarchical then things get a little more complex. There you can use ADO.NET table to store the static dependent data and then apply a filter on a view.
If its a web page you don't have to load all tabs on page load.
Desktop i think it will be more easy and it should be like that.
Only when the user click on the tab show the page and hide all the pages
associated for other tabs.
i hope all tab pages values will be on session so that user can go and come back to any tab and your Big Save at last.
Something useful related to your question i found here
http://www.syncfusion.com/FAQ/windowsforms/faq_c93c.aspx
and one more

Resources