knockout.js - broadcast data across relevant views - data-binding

I am currently undertaking an exercise to research on a number of JS MV* frameworks and select one that best suits the team's needs. Knockout is one of the contenders that I am learning about.
One of the most important requirements is for changes in the data in a view model to be broadcast to all the views that use such data. For example, lets say we have client details listed in a data grid on a page, clicking on any row in the data grid brings up a pop-up dialog where the user can edit the values of the selected row. When the change is made and the user clicks 'Save', the data is updated in the database. But what we also want is that the change be reflected in the local ko.observablearray and then for any other views that use this 'clients' collection to refresh themselves with the new data. In other words the views must refresh themselves with the data in ko.observablearray rather than get a fresh list from the database.
I have been successful in doing this - have one a single .cshtml file which houses the data grid and a form to create new row in the data grid. In this scenario, the data in the grid refreshes correctly. But when the change happens on a another cshtml file, I am not able to carry these changes across to the other views. Can this be done in knockout and if yes, please point me to an example of how and where this has been done.

I would use a Event aggregator pattern. I have made one for SignalR
https://github.com/AndersMalmgren/SignalR.EventAggregatorProxy
Install usign nuget
Install-Package SignalR.EventAggregatorProxy
If you have no use for SignalR you can then extract the relevant parts from my lib, demo here
http://jsfiddle.net/jh8JV/

Related

Can I make this simple app in App maker using calculated models for demonstration purposes?

I am new to Google App maker and I don't have a lot of experience with coding either (sorry :/). Since App maker is marked as low-coding app builder tool, I assumed it was not that hard to make a very simple app with it. However, for me it is.
I need to make a simple app for demonstrations purposes only (so Cloud SQL and other complex database solutions are not in my interest here). I want to make it using calculated models (correct me if I am wrong, calculated models are just temporary solutions, since apps need to have like real databases to be fully functional?).
My app is basically made of 2 datas: 1) Employees and 2) Departments
-> Fields for "Employees" are: First name, Last name and Department.
-> Field for "Departments" is just Department name.
My app is supposed to look like this:
1st page: Table with current employees that has a button to add new employee,
2st page: Table with all department names (e.g. marketing, finance...) that has a button to add new department name,
3rd page: Form that opens when I click on add new employee button in which I can insert their first name, last name and from drop down menu choose department,
4th page: Form that opens when I click on add new department button in which I can insert new department name.
5th page: Form (or some other widget, not sure here) that has option to insert first and last name in order to find out what department that employee is assigned to.
I tried to make first 4 pages, but I end up with forms that I cannot insert anything into them. 5th page is still too much for me.
I hope you understand my struggles and if you know how to do it please share your knowledge. Thank you very much!
Calculated models are kind of like SQL views - they are not necessarily for temporary solutions. Every time you load a calculated model the script you write under that model's datasource is ran. That script usually loads data from an external source (I.e. grabbing stock prices from an API, loading data from an external SQL server, or generating random placeholder data).
You could use the cloud SQL models for this application that you are building - your table with all department names that is supposed to be displayed in the second page could just be a cloud SQL table with one single field for a department name.
I suggest you work through the example apps so you can get a better understanding of how the different components work. Here is a link to one for you to get started.
In short, you're going to create a few models to store information (I suggest using cloud SQL as the calculated models will require code whereas cloud SQL is more plug and play through app maker's bindings). Before you create any pages try to lay out how your databases will look as that will dictate how you set bindings or program your scripts.
Asking to completely make what is essentially a combination of the tutorials already provided by Google is pretty counter intuitive - you should ask more specific questions in regards to implementation.
As for App Maker being a low-code environment, that's only partially true. For very, very simple apps (think glorified forms) you will need only a couple lines of code and can probably do everything through drag-and-drop. However, anything more complicated than a simple form will almost certainly require a good chunk of actual code. There are plenty of resources online to learn Javascript.
You might want to try a google partner like AppSynergy for building stuff like this. It might be overkil for what you need (or maybe not if you intend to build a lot more stuff).

Best way to handle and share data on Flex mobile

I am just starting out with mobile development and the data handling for Flex mobile applications seem to be plain horror. I have spent two days on it, tried about 10 different approaches and still can't find a clen working solution.
So i have a TabbedViewNavigatorApplication with many views and subviews. All of them should be able to access the same data that i want to store in a model (so basically they need to access the same model class to add, edit and retrieve some data from there).
I create one instance of a model, pass it as data to all view stacks
If i change something in one view stack and switch to another one, i see the changes and all is fine.
But if I change the model data in one view and restart the application, I see changed data in that view but if i switch to another view, it has the old (unmodified) model. I would assume that the model would be the same instance but apparently each view has its own "model" when saving persistance data.
So how do you manage shared model over all views ? Ideally i would create it once on the first app launch, and then just add / remove items from any view or subview.
Or do i need to use the SQLite for that ? In this case it seems i would need to fetch the data for each view each time a view changes to stay up-to-date with the current data in the database ?
Please help :)

Loading external data to InfoPath once only

Hopefully someone can help me with my problem.
Background
I have create an InfoPath form that is to assess project risk. It allow the user to select a scenario and in return the form returns a risk class and set of actions. The actions are displayed on the form as a multi selection list box, because I was unable to display the action list in a text box.
The form is going to be used in multiple locations, thus will be published to multiple sharePoint sites across Australia and so for easy of updating all of the scenarios and actions will be loaded from a universal SharePoint list. This will then not require the republishing of the form with every update.
The Problem
If a new version of the form is rolled out. E.g. any of the scenarios or actions change. I can not have any previously submitted forms change with it, as the previously submitted answers in the form may not be relevant in the old versions.
This is not an issue with the Scenario fields as they can be tagged to load only once. But the multi selection list box works differently and loads its data every time the form is opened.
The Question
Is there anyway of loading the data in the multi selection list box only once?
If not is there anyway I can load data into a bulleted list or some other field that I can load only once on open of the form for the first time?
Hopefully someone can help.
I had the same issue - I don't want data in old, previously submitted forms to refresh their data for dropdown, tables, etc when they are opened in the future. They need to always use the same data they were submitted with, regardless of weather the database values have changed or not.
To do this, I first unchecked the option "Automatically populate data when the form is opened". Then I unchecked the option to tell data to expire after X amount of days - so i always know the form will have data cached.
I then created a field to serve as a marker for weather to update values from the database or not. Then I used custom code to refresh secondary datasources from the database if needed. In my form loading event, I check to see if the from has already been submitted or not using my marker field.... if not previously submitted - refresh the data - if previously submitted- do not refresh data.
On submition of the form, i set my market field to indicate the form is locked and should never update its secondary sources
Hope you get my idea.
Cheers
If a new version of the form is rolled out. E.g. any of the scenarios
or actions change. I can not have any previously submitted forms
change with it, as the previously submitted answers in the form may
not be relevant in the old versions
I do not understand your problem since the previously created XML data forms are opened with XSN templates with which they have been created (i.e. previously created XML data forms are opened wh the use of old XSN template forms). If it is not so, then open a question why it is failing for you.
Also, I do not understand why do you need to load choices from external source, if it should be fixed once and forever, load it from resource XML file embedded into template itself or choices entered manually (Enter choices manually in properties of Multi Selection List Box). So, they will be stored in the used template
Please check
Free Training: Data-Driven Design - Using Default Data (Lab 1)
on step-by-step tutorial on better ways how to create in Infopath a Quiz form with Default Data (questions and answers in modules)

How to design a Master-Detail Sharepoint 2010 application?

I am in the process of migrating an Access application to Sharepoint 2010 (Enterprise). I would like to use as much Sharepoint "out of the box" funcationality as possible, but I am not opposed to creating some Web Parts.
I am struggling with the design of the "master" table in this application. The application is used to track employee productivity. Daily, about 50 users access the application and basically enter how many "Widgets" they completed that day. There are about 30 types of these "Widgets" and they don't change very often.
The table is designed with individual columns for each of these Widgets. This makes creating the Reports very easy, since all you have to do is select all the fields from the table and dump the result set.
The downside to this approach is obvikously the fact that the schema is "hard coded" (static). I have been asked (in the sake of time) to just normalize the table as much as possible (with CustomerIDs, EmployeeIDs, etc), but keep all the "Widget" fields in there.
I had proposed that we create a Master Detail type relationship where the users would Add a Row (perhaps in a GridView), select the "Widgets" they created that day (from a drop down) and enter their quantity. They generally only make 1 - 3 types of Widgets per day.
The users hate this design and want me to give them a data entry form with ALL the widgets displayed so they can just click in the box (beside the Widget they created that day) and enter their qty and then click save.
I know I could still create this type of Data Entry Form with a Master-Detail type of relationship, but I am pretty sure I couldn't using the SP Out of The Box forms. I would probably have to create a Web Part with a GridView and just populate the GridView with all the possible Wisdgets, then let the user enter the proper Qty(s) beside each widget they are made that day. Once the form is submitted back, I would then have to go through it and find any Qtys that are valid Numbers and add a (child) detail record for that Master record. (The Master Record would contain date, employee, customer, etc. etc.) The "edit" form would also have to work in a similar way.
This is a pretty "ugly" solution and I was looking for an alternative.
If I can't come up with a good alternative (and convice my manager that the code won't be too difficult to maintain or add too much development time to the project to complete it on time) then I will have to bring over this ugly, existing schema with all its wasted space and have "hard coded" stuff thoughout the application. (For instance, if I provide them with a SharePoint View to see how many Widgets of a certain Type were created, I will have to "hard code" all those values in the Drop Down and "Sum" the correct/matching database column. YUK.
Another consideration is the reporting. Right now all the reports just contain a column on the report for every widget. To preserve the look of these reports (if I use a Master/Detail relationship) will require "fancier" queries (Stored Procedures) to buld the proper result set in a "columuar" format. (And I am not sure how I would tackle laying out the SharePoint Views of the data in a similar fashion.)
It certainly would be "easier" to just leave the schema as is (and have all that wasted space in the table). I just hate developing an application that anytime we need to add a new "Widget" to the application, we have to change the application in several places and rebuild. (Although, my manager isn't concerned about that, he just wants to push it out, ASAP...sigh...)
Any help/recommendations on how to do this type of application (specifically how to create the data entry forms and views) in SharePoint would be greatly appreciated!
Shayne
Have you looked at these ideas:
http://paulgalvinsoldblog.wordpress.com/2007/12/24/implementing-master-detail-relationships-using-custom-lists/
http://blogs.msdn.com/b/alexma/archive/2006/04/10/610934.aspx
In my opinion you should be storing the data in list rather than SQL server. If you decide to use SQL server, look at BCS to build Master child view.

access forms as asp.net's listview

I made an access vba application where all my architecting was simply creating a one-to-many relationship between a "status" table and a "data" table that contained all the other details of my record. Created a form with the single click of a button with my "status" table open, and wallah,,, I got a form for my open or closed records that had dropdowns for each field where theres a related table. For activity tracking, I had to make a many-to-many table , and made a one-to-many for the status of those activities and again, clicked the create form and I was in business. To finish things off all I did was integrate a checkbox in my data fields and put buttons on my status forms that act on the record that got checked, and I was done, fast & painlessly, kinda.
Is there any ASP.net code generation of a data control in where I can just structure my MYSQL database, make the relationship and generate code of the RELATED "status" table and get my form w its related subform with text fields & DDL's automatically generated, fast? If not, what would you consider is the next best approach (i.e. using excel for replicating repetitive code)?
Take a look at http://www.asp.net/dynamicdata
As far as I know (having not used it myself) it will do what you need, ie quickly generating data entry pages from an existing sql schema.
Access can actually create .net forms when you use access 2010. (the forms are real xaml or so called zammel forms). The beauty of this system is you get to keep the same point and click approach that allows you to build master forms with child sub-forms. You not have to write one line of code and you not ever see one connection string. Only downside of this great new system called "Access Web Services" is it requires SharePoint (enterprise).
So, this is a true access development for the web, but you continue to use the Access client to build those forms. Those forms scale out to many users since you using xaml forms and SharePoint. Here is a video of this in action:
http://www.youtube.com/watch?v=AU4mH0jPntI
At the half way in above, note how I switch to running the access application 100% in the browser.

Resources