Why would I use a Kendo model instead of only using a transport/datasource - kendo-ui

I am currently looking at Kendo UI and was wandering what is the "advantage" of defining a model in my schema. It seems to work quite well without. Is this for binding reasons (i.e. column discovery for Grid control for example) ? Does it allow particular validations ?
Thanks
Pat

You can use the schema model to specify your data model. On a grid, you can for example set:
Which data type the field has (if set to number, the column filter offers e.g. 'greater than, 'less than' instead of 'contains' etc. for string values).
If a grid field is editable or not (when grid is set to editable)
Several validation properties
...
I usually receive the grid data from a web service in JSON, so everything is a string initially. By using the model I influence how these values are displayed and how they behave.
See also
http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-schema.model
and http://docs.telerik.com/kendo-ui/api/javascript/data/model
for a full overview of possibilities.

Related

Ember sorting/filter table

I am looking to add a filter/sorter table into the application. I need to choose which column can be sorted - and provide change of class glyphs up/down arrows on the columns. The filter box also needs to be outside of the table.
I tried looking at this example, but there are no glyph class changes on the cols and the filter box is inside the table.
http://crodriguez1a.github.io/ember-sort-filter-table/
I looked at this custom solution, but I couldn't see a way of locking the filter to specific cols.
http://www.jarrodctaylor.com/posts/Filter-And-Sort-Tables-In-Ember/
http://emberjs.jsbin.com/yezonaxu/12/edit?html,css,js,output
what about this one -- http://onechiporenko.github.io/ember-models-table/v.2/docs/classes/Components.ModelsTableRowFiltering.html
but the problem here - is how to create some custom markup depending on the data.
You could sort and filter your rows using computed properties. For sorting you could use sort macro. For filter you should implement your own logic, cause filter and filterBy macros does not support observing a value used to filter the array. Use the sorted and filtered rows to generate a simple HTML table or pass it to a table component of your choice.
If you will take DataTables and wrap it in ember component (custom code would work better that some generalized 3rd-party wrapper), you can achieve a lot. Including filtering by columns. It's a bit hard way, though - DataTables is big and it's API is a bit complicated. That's if you want client-side filtering.
For server-side filtering approach would be different - you render UI for filters using ember's methods, convert user's choices to string and pass that to API (which should be modified to support filtering) when asking for data.

Check if Associated View is blank in Dynamic CRM Online

In CRM Online on a customer form is there anyway that you can check if the Associated View for Assets is blank? And if its blank change a field value based on it.
Using JavaScript, 2 ways:
The associated grid is showing records related to your primary record. You can perform the same query the grid is doing using REST which will tell you if there are any records. You can then count the records, and change the field value as required. This approach is better if there are records in the database but which aren't shown in the view for some reason, e.g. view filters.
Access the Grid objects data using getRows(). As above you can then count the records, and change the field value as required. The downside of this is I believe those methods only give you access to the records shown on the form (and not any hidden by filters but still in the database) - but I don't think that that will be a problem here.
Worth bearing in mind that this approach only works client side, e.g. someone has to be actually looking at the form.
If you need to cover the a non-client side approach, e.g. workflows creating records, then you should probably look at plugin development so the changes can be performed server side.
As a side if you just want a simple count shown on form you then you should probably look at Calculated Fields and in particular Rollup fields. You might also be able to run further client side JavaScript from the count.

Implementing a reusable APEX form validation definition for multiple, similar page items

I am currently using APEX 4.0. I would like to make a validation that would apply for multiple fields in a form. For example, I want specific fields to only accept a Y or N, and they must be uppercase letters. As of now, I have one validation for each field. Is there a way to make a single validation that would apply to all these fields?
Creating Re-Usable Form Validations in Oracle Application Express (APEX)
This solution was developed on a Apex instance hosted on Oracle OTN (apex.oracle.com). This instance is currently at version 4.2.5, but the design elements discussed within this solution should still be compatible across the versions from 4.0.0 and 4.2.5.
The way you can approach your form design is not necessarily to catch exceptions through a validation step once the form has been completed and submitted.
Instead, simply consider limiting the choices that the user can choose in their input, and control how that input is interpreted once it is submitted as changes to your data table.
Pre-Validate By Defining Restrictive Value Choices
Here is an example of the OP requirement defined as a "Shared Component" through the "Application Builder" menu. Create a named LOV (list of values) with a static definition. Here, you can define the value pairs of:
DISPLAY, which is anything user friendly you want the user to see. Even if Y or N is pretty self-explanatory, explore other options such as spelling it out (such as: YES) or combining the real value with the display (such as: Y (Yes)).
RETURN VALUE, which is where you enforce what goes into your database. In this case, the uppercase, single character values mentioned in the OP requirements would go here.
This is what that LOV definition looks like:
APEX LOV (list of values) Design Screen
Eliminate Free-form Data Form Item Display Types
Following with the initial concept of a limiting LOV, convert all your form items to use display-types which use a "List of Values" definition pointing to your "Shared Component" (or Named LOV).
Use the SAME LOV definition for questions requiring the same input rules. Now the user has no way of changing the data values outside of the OP definition, and there is some flexibility to use more instructive/descriptive display values so that they are more likely to make the right selection as well.
This is an example of how a input form with the same input data types can accomplish this task with no additional validation:
Sample APEX Form Design with Reusable Input Restriction Rules
In this example, I experimented with a few form item styles, including
The standard text-box entry field. (Problematic without coupling it with additional validation logic).
Select-list entry items worked the best. See the discussion at the end of this solution for more explanation on choosing specifics such as specifying "null field values".
Radio group selection buttons work well to as they provide a visual layout of the valid form choices without additional drilling-down or scrolling.
All three options used the same LOV definition.
Examples of Data Input Using LOV Enforced Restrictions
After experimenting with different kinds of inputs, here's a few things that may be helpful depending on the situation or the deeper requirements of this OP or other readers.
DISPLAY EXTRA VALUES should be left as set to NO. This is the reason for restricting the input possibilities in the first place.
DISPLAY NULL VALUE is best as NO if all answers require a response. If NULL is possible, there is a useful third (defaulted) value that can be used for additional user-friendliness.
Sample Data Inputs and Values from the LOV Restricted Form
Notice that the free-text entry field presents additional problems with data quality without some other form of validation or checking. The other form fields provided accurate data input reflected through the target database table.
Some Closing Comments and Points for Further Study
This solution is only a partial one with respect to protecting information stored in a database table. It is not uncommon for lots of other systems, applications, programs, api's, etc. to also have access to change or add data to this back-end data source.
What if another group of developers independently created an api for managing data in the same table? Unless they read the documentation of the OP or examined existing data sets already present, their project team may not have designed an accurate interpretation of the rules which sit at this point, only on this particular APEX application.
Depending on how vulnerable your system is, it is also good practice to apply relevant safeguards, such as schema level table constraints (such as check constraints), Not Null constraints (where applicable) and even DEFAULT values settings (established by triggers or table default values).
From the Author...
Again, it isn't all necessary to go to this detail... if the input form of the Apex application offers only two choices: "SOUP" or "SALAD", it is unlikely that "BACON-ORANGE-CHICKEN" will pop up in the table after deploying the application into users' hands.
This kind of design approach skips a server round trip worth of I/O because the user already know what is on the menu at the initial page loading event.
Although the OP request is very simple and generic (Y for YES or N for NO), it presents a useful pattern for more complex input screening procedures that can happen even before the data is submitted.
Good Luck, All!
Onward.

Sorting by column in an XPages view data source

I have a dynamic view control (my own) which is fed by a configurable view data source. I need to be able to sort the view by various columns. Is there a way to do it with the view data source or do I need to roll my own? Thanks for the help.
For efficiency reasons, sorting should be handled by the domino runtime. The view must have the right columns either tagged as sorted or sortable by user. This creates the indexes within the NSF.
Then, the data source has some properties to control with sort index in being used, based on the name of the column you want to sort. The extlib DataView controls shows how this can be done in Java, through a JSF DataModel.
Also, you might consider using the DynamicViewpanel from the extlib/up1, as it does all of this for you.

How to truncate the decimal part in Asp.Net MVC3

My application is in asp.Net MVC3 coded in C#.Net.
I want to truncate the decimal part of my values when they are displayed in the TextBoxes.
The DataType for these values are set to Decimal in the database so even if i save 150 it saves as 150.0000.And when it displays a particular record it comes back as 150.0000 but i dont want it that way,i only want 150.
I have tried
#Html.TextBoxFor(string.Format("Decimal Truncation Format", model => model.myValue))
But not working..The values are travelling from many views.
So can i have such a truncation in the model itself so that it applied to that value all the time.
If not possible that way then how can i achieve it.?
Why don't you modify the property in your ViewModel to Int32? That should solve your problem in an instant!
EDIT:
This assumes that you have a ViewModel. You should never bind views directly to your db, but to a view-specific model (the ViewModel). Then you can modify that ViewModel as much as you want, so that it serves the needs of the View rather than those of the DB.
Check out the following links:
http://stephenwalther.com/blog/archive/2009/04/13/asp.net-mvc-tip-50-ndash-create-view-models.aspx
http://rachelappel.com/use-viewmodels-to-manage-data-amp-organize-code-in-asp.net-mvc-applications
http://geekswithblogs.net/michelotti/archive/2009/10/25/asp.net-mvc-view-model-patterns.aspx
http://weblogs.asp.net/shijuvarghese/archive/2010/02/01/view-model-pattern-and-automapper-in-asp-net-mvc-applications.aspx
Good luck!
Another solution: use TextBox instead of TextBoxFor, which let you initialize the field with any value.
#Html.TextBox("myValue",String.Format("{0}", Model.myValue)

Resources