Loading dropdownlists - wpf

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

Related

How can the category and product fields in Shopizer be customized, if possible at all?

I am currently using Shopizer as a sort of headless CMS, leveraging its out of the box admin pages and REST API for the content. There is a page for editing products in the admin system but I would like to add and/or remove specific fields. Making changes to the base code seems to be the most obvious solution but it is taking me a significant amount of time to implement it successfully.
Is there some sort of a config file or an initialization process to customize the fields for creating categories and products using Shopizer's admin page? What is the best practice for this scenario if the former approach is not possible?
If you need to add fields the easiest way is to add them in model objects
com.salesmanager.core.model.*
Example of an annotated field
#Column (name ="IP_ADDRESS")
private String ipAddress;
Once you restart your instance the new field will be available.

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.

How to force two instance of the same app (DNN/2sxc) to read from the same stream?

Sorry if my question is silly but I'm new to DNN/2sxc, I've spent the whole day trying to figure this with no success..
I have two instances of the same app, one in the home page and the other on its own page, each one must have its own view template (I use Razor).
My problem is I cannot figure a way to make the two apps read the same data, so every add/edit/remove/re-sort in one of them will be reflected to the other, currently each app has its own data and therefore they are unusable in my case.
I've tried to use a 'EntityTypeFilter' inside a 'Data Query' and use it in both views (as in the News-Simple demo video), it worked and gave me all the items in the two views, but another two problems come with this solution:
1- now I'm unable to use the toolbar to (add/remove/reorder,.. etc) any of the items , as you can see in this image, which is a show-stopper for me,
note: this is the toolbar I use:
#foreach(var item in AsDynamic(Data["Default"]))
{
...
#Edit.Toolbar(target: item, actions: "new,edit,replace,remove,moveup,movedown,instance-list")
2- the 'Content Demo Item' is also visible in the list, but it is not that important since I can delete it and use one of the real data items as a demo item.
I appreciate any kind of help.
Thank you.
So the first thing you should know is the difference when using content-items as data (to query, etc.) and when using it as assigned-items (where each module-instance has a subset of items). Here's the blog that should help you understand the difference: http://2sxc.org/en/blog/post/12-differences-when-templating-data-instead-of-content
So when you want the "manually and easily control the exact items displayed, their ordering etc." you want to use the "content-assigned-to-instance" which also gives you the simple add, delete buttons, as these don't really delete anything, but just remove the assignment from the module-instance.
Now your case is a bit special, in that you want to re-use the exact same set in another module-instance. There are a few ways you can do this:
Same View
if it's exactly the same view etc. just duplicate the module using DNN-features (the add-existing-module-to-another page)
different view
if it's a different view (maybe more compact, etc.) you again have multiple options. The first is to mirror / duplicate using the dnn-feature, and just put an if-im-on-this-page-then-show-differently or inject another CSS. That's probably the easiest without any dev-know-how.
The harder, but possibly nicer way, is to actually to use a new template, and tell it to retrieve the items in the way they are configured in the other module - let's say module 1 is the original, module 2 has a different template wanting to access the items of module 1 in exactly the same order as given in 1. They way to do this is simple, but requires a few lines of C# code in Module 2.
You need to create a new ModuleDataSource (https://2sxc.org/en/Docs/Feature/feature/4542) object and tell it that it's from Module 1. If you've never done this, it's basically that your code can create a query just like the visual designer, but you have more control - see the wiki https://github.com/2sic/2sxc/wiki/DotNet-DataSources-All. The Module-Data-Source in the visual-query-designer doesn't allow you to "switch" modules (a advanced setting we may add in the future) but the object has a ModuleId property which you can set before accessing the data, making it "switch" to that Module. here's the Pseudo code in your Module#2 razor...
var otherModData = CreateSource<ModuleDataSource>();
otherModData.ModuleId = 1;
foreach(var itm in AsDynamic(otherModData["Default"])) {
...
}
That should do it :)

How to know if you're Dropping in the same app instance where you made the Drag in WPF?

the title pretty much explains my issue:
I am right now taking care of drag & drop in my app. I can have many instances of my app running at the same time, and I can drag from one instance to the other without trouble.
Now, I would like to know if I'm drag & dropping "internally" (i.e: the drop occurs in the same instance as the drag) or "externally" (the opposite)
I went this far: I need to add to my dragged data a unique ID (something like a PUID) that identifies the app where I'm making the drag. Then I can just compare this id to the one I have locally on the drop and see if it is the same.
I have no problem transferring such info in my drag Data, the issue is more to find this UId.
I have been thinking using the Process.GetCurrentProcess().MainWindowHandle; but I'm not sure if this is a good idea.
What option(s) do I have to make this work?
I would simply create a readonly Guid that gets set when you start your app.
You can put this wherever your main logic lives (MainWindow or ViewModel).
Here is a snippet:
public class MyViewModel
{
private readonly Guid mUID = Guid.NewGuid();
// In case you want a property for it
public string UniqueApplicationID
{
get { return mUID; }
}
public void OnDropHandler(MyViewModel objectBeingDropped)
{
if (objectBeingDropped.UniqueApplicationID == mUID)
return;
// Handle drop normally here
}
}
The D-n-D is much like an UI activity, than an internal one.
I would distinguish two contexts: dropping a file, and dropping some object (e.g. VS designer). In the first context there's no problem at all, because it doesn't matter where you pull the data. In the second case, you should know what object has been chosen. For instance, you have a listbox with many items (e.g. the alphabet chars), once the user D-n-D any of those items, the internal operation is a simple reference to the selected object. By pulling the data from another app, you won't be able to find your object, because the source is different.
In case of structs or strings, you may wrap them with a GUID, as you correctly proposed.

Flex 4 data management - how do I approach this?

quite an explanation here, hope someone has the patience to read it through
I'm building an application in Flex 4 that handles an ordering system. I have a small mySql database and I've written a few services in php to handle the database.
Basically the logic goes like this:
I have tables for customers, products, productGroups, orders, and orderContent
I have no problem with the CRUD management of the products, orders and customers, it is the order submission that the customer will fill in that is giving me headaches:
What I want is to display the products in dataGrids, ordered by group, which will be populated with Flex datamanagement via the php-services, and that per se is no problem. But I also want an extra column in the datagrid that the user can fill in with the amount he wishes to order of that product. This column would in theory then bind to the db table "orderContent" via the php services.
The problem is that you would need to create a new order in the database first that the data could bind to (orderContent is linked to an order in the db).
I do not want to create a new order every time a user enters the page to look at the products, rather I would like to create the order when a button is pressed and then take everything from the datagrids on the page and submit it into the database.
My idea has been to create a separate one-column datagrid, line it up next to the datagrid that contains the products and in that datagrid the user would be able to enter the amount of that product he'd like to order.
I've created a valueObject that contains the data I would need for an order:
Code:
package valueObjects
{
public class OrderAmount
{
public var productId:int;
public var productAmount:int;
public var productPrice:Number;
public function orderAmount()
{
}
}
}
My idea was to use a service to get all products from a certain group, populate an ArrayCollection with the data, then transfer each object in that ArrayCollection to an instance of the Value Object above, add the value object to another ArrayCollection that would the be used as a dataProvider for the one-column datagrid (I would only display amount which would be set to zero at first, but use the other data upon transfering it to the db)
I've tried to use the results from the automatically generated serviceResults that retrieve the products for the datagrid and put in a resultHandler that transfers the valueobjects, however this does not seem to work.
Basically my question is this: Am I approaching this thing completely wrong, or is there a way I can get it to work the way I planned?
Would I need to create a completely new service request to get the product id:s, and price to populate the one-column datagrid.
I'll post some code if that would help.
Thank you if you read this far.
Solved it by creating a Value Object class to hold all the info needed for each row in the grid and from the php service that returned all products in a group, I looped through the result and transfered the data needed into my Value Object.
I then added each Value Object into an ArrayCollection and made that the dataProvider for the dataGrid.
No need to use two grids. I forgot how logic things get when you think of datagrid data just as an ArrayCollection and forget the visual presentation of it on screen.
Put in a few itemRenderers and the whole thing is beautiful!

Resources