Access Main View data from ajax partial view - asp.net-mvc-4

Situation:
Let say we have a list of products and each with a bunch of orders. I have a my index view that has this list of products contained in the model. I iterate over the list and display a list of products on the page. I add an jquery click event for each project, the click event loads a partial view for each order beneith the product list.
Order partial view would look like this:
#model Order
<p>#Model.orderNum</p>
#Html.DropDownListFor(Order.CustomerName,CustomerNameList)
<input type="submit"/>
Index view would look like this:
#model List<Products>
#foreach(Product p in #Model)
{<button class="product-button">#p.productId</button>}
<div id="orderDiv"/>
then I would execute the following javascript for every order for the product:
$("#orderDiv").append($("<div></div>).load("MyController/Order/[order ID would go here]"));
This would load an order with a seperate partial view for each order id the product had.
Problem:
The simple solution would be to have the CustomerNameList in the Order Model. However, I don't want to load that data to the page so many times. Is there a way I can put it in the ViewBag or store it somewhere else so this list is available to the whole page?
Notes:
I don't want to use one partial view for all of the orders (ie. have the order view model be a list and iterate over it in the partial view) because I want to be able to submit each order individually (to save it)
I also might need to use this list of Customers on some other part of my page. I would like to keep it available. For example maybe I have a button that says new order and this uses ajax to load a parital view and that partial view also needs the customer list. I don't want to send that data to the page so manye times.
Can I do this?
Is this just a bad way to do this?

Not too sure why you would want to load a dropdown list of users, for already, existing orders. That means you are wanting the facility to change WHO made the order?
However, if you must, you can load your customer dropdown list as an empty dropdown with a class of customer, you can then make an internal call to get the json for customer, and then load up all your instances of class customer, with the data from your json call of customer data.
This would allow you to have 50 orders listed, with one single collection of customers data.
personally though, you should have relationships with your models using foreign keys, or using a viewmodel that would already add in your customers list, you would also only wish to show full order details to a user, if they clicked on the row to show full details.
Even if someone goes mental on the screen and clicks all 50 to look at, you should still be able to handle these request without much trouble, otherwise and likewise you wont be able to have 50 customers all looking at there baskets at the same time, or 50 customers all searching the products database at once!

Related

Adding new product with category tree - specific price problems

I installed an add-on for bulk action (called ba_importer v 1.1.24), I upload an Excel file with my data and create a group of products.
I can set the categories' tree or manually add ID of main categories and associated. I tried with no luck to use the tree features (like Home/Products/etc) and so I use all the ID of main category and all the associated. The result is a product with the correct categories set, but with no specific price from the customer group linked to a category.
I tried to edit a single product, remove all categories and set it one by one (set one, save, set one, save etc.) and then the specific price from the group linked to a category appears to the product.
Is there a better solution? I'm thinking about make a personal PHP page that reads an Excel file and sets all the information about the product, but I'm scared to face the same problem with the specific price. 
There is no such thing as "category-related specific price",
if you have specific prices tied to customer groups , these are created as a result of the add/update product action with ps_specific_price DB entries having id_group with your restricted ID.
It is likely that the bulk module acts directly with DB queries to speed up things and bypasses this operation, I've seen this behaviour with those kind of modules in the past.
Since you are talking of a paid add-on, I would definitely seek help from the developer.

When relating 3 entities in CRM 2011 using Advanced Find only 2 entities show up in edit columns

I'm trying to create a view in CRM 2011 that will show a few columns from Customers (Account), Orders (SalesOrder), and Order Products (SalesOrderDetail). I already know I need to start at the child-most entity so under Advanced Find I select "Order Products" under Look for. When I do this I'm able to select columns from Orders but unable to select columns from Customers.
Is this even possible to accomplish in CRM?
I'm trying to create the following result set:
Account.Name,
Account.Email,
SalesOrder.OrderNumber,
SalesOrderDetail.NetAmount,
SalesOrderDetail.ShipDate
I verified that you cannot manually add a second link within a view query. To my knowledge it is also not possible to add these columns though javascript. You can get the account name in your view simply by using the account lookup on the Order. If you need for the account email to also be in the view, then I suggest you add this field to the order entity and populate it with post callout logic on the account.
I Second Zach’s idea, but suggest adding a direct relationship between customer and orderdetail . This way you can use fetchxml to show account.email or any other account.* for that matter.
The downside is you’ll need to sync order.customer changes to orderdetail.customer.
The better option is to simply create a report and show that in an iframe or a webresource.
This is not possible even if we edit the fetch xml it wont work

How to arrange testlists as we needed order in telerik test studio

My test list is
Vendor
Employee
customer
Initial Navigation
I want to display like
Initial Navigation first then
customer
vendor
Employee.
How can I arrange in this order.am not asking about tests in the test list.test list itself
need to re arrange
The grid displaying the list of Test Lists, like many other grids, can be sorted by any column by clicking on the column header. You could give the items alphabetical names then sort by the name column.
I do not know of any way to otherwise specify a particular order of display.
If this is a feature you'd like to request, http://feedback.telerik.com/Project/117/ is a good place to do so. Please be sure to include some information on how and why you'd use this feature so that it can be properly prioritized.

Adding lookups to given view

I'm just getting into Yii. I have a simple relational db. I have a "client" table related to "orders" table (client:id to orders:client_id). If I build my CRUD for orders i naturally see client_id, however I'd rather add a lookup for client name somehow
I have found how to do this on new and update _forms by adding a dropDownList. The list based views seem a little more complex. I can see that actionIndex() in the controller is gathering data and passing it to index.php, finally through to _view, but I can't find any help on where and how I should break into this with my lookup returning the client name
I'd appreciate any help
thanks
Check the Yii documentation about relations. You will need to create a relation in your orders table, lets call it client, Then in your list view where it generates client_id you can put client.name instead. Now you will need to make sure that you have the appropriate label because in the generated model it will only have a label for client_id, and you need a label for client.name. Yii will guess, or you can add it, or you can modify the label for client_id, and instead of using client.name in the view you can use
array(
'name'=>'client_id',
'value'=>$model->client->name,
)
I tend to gravitate towards more explicit definitions rather than shortcuts, but to each his own.

Ruby on Rails 3 - Modeling Products with Many Categories / Attributes

I am working on my first Rails website, a sort of shopping website: there are products sold through the website, each with multiple unique attributes.
The use case I am imagining is: a user visits the site looking to buy a used bed, they click through several higher categories until they find a bed of the correct size, something like this:
Furniture
---> Couch
---> Dresser
---> Bed
-------> Size
----------> King
----------> Queen
...
At each time the user clicks a more narrow category, they are supplied a menu with the next level of detail (a la NewEgg). When "Furniture" is clicked, all furniture is displayed, and a menu with the types of furniture appears. When "Bed" is clicked, all beds are displayed, and a menu showing the various attributes of a bed appears, etc.
So far, I have an "Item" parent class which contains all the attributes of every item sold through the website (price, description, etc...). I am stuck with what to do next.
My first instinct is to have subclasses, but they don't seem to be that useful. There is nothing about the "Furniture" subclass that would have anything new in it, other than definiting it to be furniture. Also, each parent class needs to know about its subclasses.
What sort of design pattern should I pursue to cleanly implement this model? I've been looking into nested sets, but I am not completely sure that's the way to go. Any guidance is appreciated.
Thanks!
Your categories clearly form a tree, which is probably why you're thinking about a class inheritance tree. However, you are correct that this isn't the right model, since subclasses do not add any functionality over their parents.
You should have a single "Item" class, which is a node in the category tree - with references to its parent category (another "Item", or null for the root) and its array of children (all "Item"s).
The correct place to store the information about the tree structure is the database. In your items table, add a "parent_id" column as a foreign key - to the items table.
As the user navigates down in the tree you show the subcategories by querying for the items whose parent_id equals the current item id.