mvvmcross MvxActionBasedTableViewSource as groupped table - ios

I use MvxActionBasedTableViewSource for my custom binding on common grids.
Func CellCreator is really great and everything works fine with that.
But. What way is it expected to deal with groupped tables?
I need some dynamic binding with them.
So, does that mean that I should implement that logic by my own and CellCreator can not be used for such behaviour anyhow?
Thanks!

MvxActionBasedTableViewSource is designed for simple tables only - so cannot be used for grouping without some changes - e.g. via inheritance or copy and paste.
For a list of available TableViewSources, see What class to inherit from for bound table source
For an example of grouping, see Creating UITable with section using Mono touch and slodge mvvmcross (the code is out of date, but the principles are still the same)

Related

MVC5 option group maintenance table for CRUD

What is the best approach for maintaining (CRUD) on an optiongroup list that is driven by two sql server tables?
The option group is like this and is driven simply by two tables (parent child)
OptionGroupOne
ItemOne
ItemTwo
OptionGroupTwo
SecondItemOne
SecondItemTwo
etc…………….
Was thinking of just looping through in an unordered list?
I’m using entity framework 6 with MVC5 don't really want to use javascript.
This is a long way if you don't seem to have anything ready yet... I bet that's the reason why no one wants to start explaining.
You should organise the Lists in nested ViewModels, the OptionGroupViewModel and the ItemViewModel. The OptionGroupViewModel has a string property for the name and a List<ItemViewModel> property for the children. So the main model should be a List<OptionGroupViewModel>.
In your cshtml, Using the Html.EditorForModel() extension method on a the latter, you should get some View Results already, the EditorFor... methods are quite intelligent and will generate views based on the data structure.
Now you will need a MVC Post method with the List as the model and you will find all updates there, You need to map them back to the Entity Framework model (or whatever kind of base model you have). As you mentioned in your comment above, you want just a "way of editing the titles of each option group and the title of each group". This would be pretty simple but is half way to CRUD, and Delete + Add are much trickier in that scenario.
Using frameworks like Knockout JS is a big gain here but requires some learning and will introduce JavaScript to your project. The linked tutorial is for Web.Api but it will also work for MVC.

Xamarin Android Azure Mobile service good design

I am building an Android app via Xamarin Mono for Android, I recently started using the azure mobile service .
I need guidance regarding the architecture that should be designed for this functionality:
3 Fragments in my app will be using the Mobile service database, all of them using the same table Item:
Fragment A - List Fragment - querying Item and populate the list with the result.
Fragment B - List Fragment - querying Item and populate the list with the result (with different ListItem layout than Fragment A list).
Fragment C - Fragment - Insert an item to Item table.
I currently have a Adapter class implementing BaseAdapter that holds the table and queries it and insert to it, and then populates the Fragment A list.
However this way I'm unable to show a different ListItem layout in fragment B as the adapter is already set to a specific layout.
I have tried to find documentation about the design standards when using azure mobile service but with no luck.
I would be glad if someone could refer me to a guide like that, or explain where should the MobileServiceClient, MobileServiceTable etc. should be held and where should the table methods InsertAsync, ToListAsync... should be called.
Thank you
Since you already have a instantiated class that I assume is populated there are a couple different ways of going about this. You could create an abstract base class adapter that contains all your code except for the GetView methods, and then create a specialized class adapter for each view that has the GetView method that applies to that view. When you fire up the fragment just pass it the list items in the constructor.
Alternatively (and I'm not sure how well or not this would work since I have never tried it) would be to keep 1 class, but set a bool to designate if it is View A or view B you want to display. You would need to have the fragment change the flag as appropriate for your particular requirements.

Implementing Select List Lookup ViewModel Attribute

I'm trying to implement a more customisable version of using ViewModel attributes and a Model Enricher to populate viewmodels lists like in this this question and associated blog post.
I would like to be able to specify the method on my select list interface from the Attribute.
Each Select List service I have returns an IEnumerable that I use to make a select list and presently exposes an All interface as the sample does. I can easily use the All method because all interfaces provide that. However I often wish to able to use other methods like the AllTradingCompanies() AllManafacturingCompanies() methods of my select list class to get filtered lists.
It is presently looking like I may have to implement a Custom attribute to map to specific e.g. [AllCompanyList] attributes but that moves me away from the nice generic method that the existing version gives me. I guess I could use it to complement it but then its starting to lose some of the charm. I also am implementing IModelEnrichers which can do custom per view model logic.
Any thoughts on a nice way to implement this?
I implemented the solution using pairs of Attributes to define a requirement for data on a ViewModel and a provider of data a repository or a service within my domain. See my follow up question asking whether this is a good idea.

Should the model be responsible for holding lists that will ultimately populate dropdownlists in the view?

This might be similar to ASP.NET MVC - Populate Commonly Used Dropdownlists.
I want to populate DropDownLists. Some of it is static data. Some of it comes from the Database. A couple of times I found myself forgetting to call the code that populates my lists and sets the ViewBag accordingly. It is almost worth adding a unit test for this. The only way I think that this suits a unit test is if you place it in model/service. Is there a best practice for this kind of thing?
I'd suggest that the data is contained within the model but is perhaps constructed by a html.helper method. this way, you keep the plumbing markup out of the view and leave the controller free to invoke the neccesary view and model.
You could also of course hand it off to a partialview with an <IList<SelectList>> model.
cats and their skin :)
If you follow the spirit of the pattern then the Model should supply the View with everything it needs to present to the user that's not static. If you have static dropdown lists then you could say that these could be constructed within the mark-up. If you are passing a SelectList to the View from your Action then I'd stick it in the Model to make things simpler and more coherent.
My rule of thumb is that the data must somehow be in the model, either as a ready to use SelectList or at worst in some container that can easily be turned into a SelectList using a LINQ-to-object call.
The bottom line is that the view should never contain any non trivial code.
EDIT (answer to your comment):
I try not to put too much code in models. Models are more like a simple bunch of data gathered by the controller and used by the view.
Regarding simple and/or common things such as the days of week, I believe an HTML helper is the most elegant solution. See WayneC's answer in this question.

How to create OData based off RFC with multiple tables in the output?

I am working on a large project at work that requires me to create OData's for a large variety of Remote Function Calls. I was able to work out how to model and create OData's for simple RFCs; however, I am struggling with more complex RFCs that use multiple tables as well as simple exporting and importing parameters.
I want to output these tables as well as the importing and exporting parameters via GetEntity and GetEntitySet with just one call. I have done extensive searching online to find solutions but the best solution seems to be redefining the RFC's or calling the OData multiple times which is not ideal.
Is there any way to combine multiple tables with several entries in the output? When I say output, I am referring to the resulting XML from GetEntity/GetEntitySet.
For example, take the below fake RFC definition that takes a PERNR, and outputs a list of direct reports and a structure of employee details.
IMPORTING
PERNR
EXPORTING
S_EMPLOYEE_DETAILS
TABLES
T_DIRECT_REPORTS
Is there a way to combine the table, structure, and importing parameters into one output?
The first thing to understand is that the OData protocol is not intended to solely work like classical function calls. It is based however on entity/relationship kind of model.
So in your case id sugest to create an entity type named 'Employee' with the appropiate properties of your structure S_EMPLOYEE_DETAILS. With this you can e.g. implement the method GET_EMPLOYEE_ENTITY to retrieve a single instance of an employee via PERNR.
The next thing to do would be to get the direct reports of this employee. Since this is a relation 1:N from Employee to Employee in your case you can create a navigation property called 'DirectReports' with appropiate cardinality. Then in your GET_EMPLOYEE_ENTITYSET you can return the instances of table T_DIRECT_REPORTS (note that navigation property is not empty and you have to read the keys of the parent!).
Once you got this working you can move on to the 'best-practise' and implement the method GET_EXPANDED_ENTITY with filling the expand clauses, which is in my opinion the preferred way as you dont need to implement two seperate methods and is consiered faster as well (if many expands happen).
Both methods of implementation can be called via
GET EmployeeSet('12345678')?$expand=DirectReports

Resources