Display tabular data. Is there any option other than looping through dataset and generating a table in razor? - asp.net-mvc-4

In my MVC application, I need to display data in tabular format (no edit, only readonly) in one of the razor view. Some of the columns should be hyperlink, a couple of columns showing image, and rest columns in plain text.
I know one option is to loop through each row in the dataset (model), and build the table. Anyone has any idea if there is any other way of doing it? (without any third-party control)
Any advice on this, much appreciated.

You can use Phil Haack's tabular template in aspx
or my updated version that is done in razor
About the Visual Studio Add Controller and Add View templates
You may also get some ideas from the List.tt template in [Visual Studio Install Directory]\Common7\IDE\ItemTemplates\[CSharp | VisualBasic]\Web\MVC\CodeTemplates\
My article on changing/customizing that

The closest "non-third party" control I can think of is the WebGrid, but even that isn't included in the ASP.NET MVC distribution if I remember correctly (you might want to check though as I'm not 100% sure).
However, using a simple foreach to generate your table isn't a bad way of doing it either, especially if all you need to do is display some data.

Why no third-party control? Personally, I like datatables.net.

Related

Mechanical Turk: Categorization project via Request UI diffictulties

I am a newbie in MTurk, and I am trying to create a very simple Categorization Project via their Requester UI (rather then the API).
Each batch I use has 10 items (question and possible answer). I have searched their documentation and forums with not help and so I have several questions:
When i use their Standard Categorization template, I have no option for modifying the HTML and layout (as shown for "Tagging of an image" project). the only formatting options are for the categories, instructions and includes/excludes. Is there a way to edit the HTML of the standard template they provide?
In the Standard Categorization template, while my input data file (csv file) contains 10 items, only 5 are shown (tried with 6, still only 5 are displayed in the preview). Is there a way to change this limitation?
When I try to use the "Create HITs Individually" (rather than the standard template, as explained above), I have the "Design Layout" options, but I cannot find a way to make the questions in the "form" required (which is possible via the API). Is there a way to achieve this?
If you stick to the standard project templates, you can't modify them. That's the reason to create HITs individually (through the RUI or via the API).
You'll have to show us your CSV file, because it's not really clear from your description what the issues could be.
Your third question is unclear, but basically for creating HITs individually, you simply do standard HTML markup and put in ${variablename} placeholders wherever you want one of your CSV upload variables to be placed.
If your project is at all large, I would definitely recommend going through the API. It's simply much more flexible than the RUI for creating any kind of customized design.

how to visually design reports generated by dossier?

I have used dossier to generate reports in my application. Now I want to visually design my reports generated by dossier like charts. Is there any gem available to do that? Can you please any one help me (or) tell me to how to use iReport in rails application.
Dossier currently does not provide any visualizations (though that would be a nice enhancement). I have been using to to power various JS charting libraries using JSON. Any report can be converted to JSON format by adding a ".json" extension to the report url. Generally I have found that I will have to alter the way I write the sequel selects slightly to get the right JSON output, but overall have had good success with this strategy.
Let me know if I can answer any other questions on this.
Thanks!

Workflow for modifying existing crud scaffolded model, views & controllers

I am in the process of learning Yii framework. I have always previously built plugins in wordpress and I have never used a PHP MVC framework before.
Assuming I have designed my database
Used Yiic shell - console to model the db and create crud classes etc.
Modified the controllers and views to my custom requirements.
Now the client requirements change and an extra field is required in the database.
I modify the database to add for example "tel2" field to the customer table.
Do I need to update the model, view and controller manually to incorporate these changes or do I save customisations then get Yiic shell to re-scaffold the model, view & controller, then re-write the customisations manually?
I am sure that I can do either, but is there an easier way / is there a way in which you all work which makes your lives easier?
This was a question on my mind also when I began Yii.
The simple answer to it is you dont have to change everything. The Gii module is a really powerful feature of Yii and after making the CRUD and the model after a DB table, and if you have your own custom functions and methods and then you decide that you need to alter a table and add a new column to it, all you need to do remake the model in gii and it shall show the the modified code in a seperate link tagged as "diff".
Gii only generates the code, it does not overwrite it.
Now all you need to do is open up the "diff" make sure that you do not overwrite the code as there would be an overwrite button as well. After you check out the "diff" code, it shall show the new columns and the new properties highlighted, now all you need to do is copy the requisite changed code into your original code.
This way, you can do as many changes as you want with everything remaining intact.
There is also another method. You can use a base class and extend all your code into another file. This way, all you need to do is change the base model and everything still remains intact.
I think this should have answered your question.
Regards,
You should look at gii as a tool that gets you started quickly. But once you created your models and maybe CRUDs you can usually forget about it. Your project code evolves and - if it's not a very simply project - you will have a lot of manual changes to the auto generated code anyway.
So every time you touch your DB you will update the related files. Often this only involves to add a new attribute rule in rules() in your model, and adding another input field to the form view.

Form development optimization

Like many web developers I do forms all the time. I found myself doing the same all the time: placing input fields, assigning a name to each, ajax the form, then create the php which involves to assign a $php var to each $_REQUEST['var'], escape and validate data, build the html and emailing the results...
So I find that 70% of the work I repetitive but I just can't duplicate a page and change the fields. I end up wasting more time reformatting, deleting and adding different fields than creating from scratch.
I started planing to program a "list of IDs to html+php" converter in which I'd input all the IDs and this would output the basic html and php. Then I thought: there's got to be thousands of developers that go through this, I'd be reinventing the wheel. So this is my question, I'm trying to find that wheel that somebody must have invented already.
I found this: http://www.trirand.com/blog/jqform/ which does more or less what I'm looking for but it's an expensive solution and it has too much functionality for what I'd be using it.
Which tools do you use to optimize repetitive task about html and php?
Creating forms using plain HTML is cumbersome and time consuming. The task will be much simpler if you use an open source form library. I use Zend_Forms extensively. You could also look into the one provided by EZ Components
These form libraries allow you to specify various form elements, validators for each element and data filters (string tags, lowercasing etc...). Once you have specified these the library automatically handles the rendering of forms and further if there are errors it will renders the errors as well. Usually these libraries render the forms with certain predefined mark-up (HTML) but it's configurable as well.
If you start using one of these libraries you would save a lot of time while creating forms. In-fact I would suggest you to use a framework such as Zend or Symfony for your projects.

How do I bind a tree control to a data source in VB .NET?

Edit:
Duplicate
I'm new to .NET, and I've taken on a small work project, converting an existing VB6 product to a current version of VB (its either that or learning VB6!). This product is an internal desktop application (not web-based).
I need to create a new tree view, that is linked to a particular table.
Each row in the table has a parent id that links back to the table's primary key, and that defines the node hierarchy. So that relationship needs to be indicated in the databinding.
Am I able to use the standard treeview control in Visual Studio 2008, or do I need something extra to make this work?
You can bind a tree view control using an XML file which will define your nodes or you can bind it by querying a database. Here is an article from 15 Seconds which has a pretty thorough tutorial on using the .NET TreeView control.
According to another question, this isn't possible, as the normal treeview control doesn't support databinding.
You'd need to either programatically populate, or use a third-party component (I've used Developer Express in the past with C++/Delphi components, they are fantastic!).