web2py sqlform grid modify edit view - sql

How do I modify the edit view in my SQLFORM.grid - size of input fields, drip down menus, etc. Documentation is poorly written so any examples would be a big help.
Thank you

The SQLFORM.grid uses the assigned widgets in your database model.
So to change the output of the grid on widget level, change the model. The fieldtype defines the auto selected widget. See the field-constructors part of the book.
If you want more fine-grained control over the result you could tweak the widgets, override widgets, create your own widgets, patch the generated code in the browser using jquery of choose to write the entire grid yourself. Also you could change some parameters to the grid based on some SQLFORM parameters it passed through to the generated SQLFORM. Try the viewargs argument to the grid to alter the parameters sent to the SQLFORM when viewing. You might want to offer it something like dict(formstyle='divs') or use the ui parameter to offer a dictionary with classnames you use to apply your own CSS. ref
About the choice for using the grid in the first place:
These are two high level objects that create complex CRUD controls.
They provide pagination, the ability to browse, search, sort, create,
update and delete records from a single object.
So for very fine grained control it might be best to write your own grid instead of using such high level objects.
I'm not saying it's impossible to finetune the grid using the model and some javascript, but because it uses so much of all the other elements of web2py diving into the grid without much further web2py knowledge is quite a steep learning curve.

Related

Simple data populate data with Kendo UI

Hello I'm quite new to Kendo UI so my question is probably simple as well.
I am working with datasource of Kendo UI (Javascript) that reads a simple JSON object from a remote source, what works fine.
I struggle now with populating the data into single text fields within the HTML page. I find some example on Kendo UI documention talking about "template", "model", "columns", "binding", etc. but there is nothing I think I can adapt it to my needs. All examples I find are focussed on Kendo Widgets or "grid", what is not what I want.
Example:
I read the JSON by "datasource" object from remote source, looking like this:
[{"productid":"30","title":"apple"}]
In my HTML there are two input fields, one with ID="productid" and another one with ID="title"
I don't need a precise code solution just a hint/link how to proceed to populate the JSON elements into the value attributes of the two input fields. If this is possible is there also the other way possible like storing the values of the input fields back to a datasource and send it back to remote server for saving/updating purposes?
Any hint is welcome!

Create and use global view in C# WP8 XAML

I was trying to digg something on this topic before, but have no luck. What I'm trying to achieve is pretty simple, but seems to be hard to achieve :-)
I have a WP8 app (C# XAML) and I need to implement global messages (something like toasts) which could be displayed across whole application no matter of current navigation processes. Such toast message(s) should be displayed even while user is navigating between pages. To use the built in toasts is not a way (in case some other solution exists) since I'm possibly in need to have more than one message displayed at the same time (each one is independent of another) and should disappear after specified period of time.
So, my question is. Is there any way how to implement and use some kind of global view instance which sits above all pages and can be called from any page?
All I found until now is the possible ability to use PhoneApplicationFrame, but I would like rather avoid that if possible. I'm still unsure if this is even the way it can be done, but I suppose so. Do you have any alternatives or assurance this is possible and only way to achieve this goal?
Thank you all for your time and answers.
You can have UerControl for the Functionality you are looking for. It is Control that has its own Seprate Xaml and cs file. You can call it from any page into your Project. UserControl provides the base class for defining a new control that encapsulates related existing controls and provides its own logic. You have a XAML file and C# class file for a user control. The class file extends the UserControl class and adds additional behaviours and properties. The XAML file encapsulates the composing controls, the styles, the templates, animations and whatever necessary to form the UI. Since it is a just composition, it is really easy to create. for more Reference you can go here Why and how to create a User Control in Windows Phone
I have ended up rolling my own custom navigation using a single master page. As such any global controls are instantiated once at startup. Navigations are called from my viewmodels and result in usercontrols being removed and added to the visual tree as necessary (using transition animations to give the impression of page navigation) This works but im not sure whether it is best practice and would appreciate some opinions and comments on this. Certainly it solves the problem of global views described.

ASP.NET MVC Set texts in the View or in the Controller

What is the best practice in MVC (for testing, SOC and scaffolding) for setting texts (for exemple page title, h1,h2..)
Is it better to do it in the controlle, fill a viewmodel and send it to the view
or directly typing texts in the view?
Also I will propably use ressouces files for global texts (like button text, menu texts) and local ressouces for view specific texts.
The view is merely to present the output to the user. Depending on your requirement you can either:
1) Type the text in the view directly <h2>Hello World</h2> (for static content that will not change)
The latter two options are for ideal for dynamic content, where the content could be received from a database or some additional input.
2) Use the ViewBag to pass information to the view (in which case you would set it in the controller ie. ViewBag.HelloWorld = "Hello World" : <h2>#ViewBag.HelloWorld</h2>
3) Use a model to pass the information to your view. This should be your preferred option where possible. In your specific case you could use the controller to retrieve the content from your global resources, bind it to the model and pass it to the view.
The logic on where to get the data should come from the controller and the View's function should be to merely display it.
I recommend binding properties on the viewModel to the UI.
This is not only more testable, but it's also more flexible. It makes it easier to implement features like mult language support etc.
I recommend avoiding hard coding text in the markup if you can

Backbone Structure Tips

New to Backbone and wondering if any Backbone experts can lend their advice as to how to structure the following application:
Users log in to view the Dashboard. The Dashboard has 6 Panes and the Content of each Pane is determined by each User's Preference List (a Backbone Model with attributes panelone: contentA, paneltwo: contentD, etc...)
Above the Panes is a horizontal list of Content types. The User should be able to drag and drop the Content type over a Pane to save it and render the Content in that Pane immediately.
For example, if ContentF dropped on Pane3 then Pane3 saves ContentF ( Model.set('Pane3: ContentF' ) and updates itself with ContentF's template.
Specifically, How do I divide up this functionality between Router, Views and Templates?
Thanks,
AC
I can't consider myself a Backbone expert, anyway that's my two cents.
I suggest you to use Marionette, a framework built on top of Backbone that ease the things a lot.
You could setup your dashboard view as a layout, and each panel as a region of that.
This way you could update each panel's content without affecting the others and have all the events and stuff attached to your old view be cleaned up by Marionette's build-in memory management.
Also I don't think your router should be too affected by a change in panels content, it should just render the view assigned to that specific content, so it just has to be able to access the list model. Each of this views will have their specific template and that's all!

Extend Page Property with custom controls in Sharepoint

Sharepoint is quite limited when it comes to multi-Lookups because it saves that information in strings. So I changed the Page-Property
"Elements (MultiLookup-> elementIds" on the propertyPage
to an inserted List "PageElements":
"
(SingleLookup)pageId , (singleLookup) elementId"
Because this is quite hard to maintain for my content admins I want that they can enter that information in the page properties like before instead of adding lines into "PageElements"
Therefore I want to add a control that handles that.
I do not need a solution for the task how to achieve that specific function, but a general hint how to add any custom control into a Page property.
I starting point link would be very nice. I just doen't seem to find the right words to feed google with my topic.
Solved this by using a custom field type with that logic. Basicly Described here: http://avinashkt.blogspot.de/2011/07/creating-custom-field-in-sharepoint.html