This project is read-only.

DataGrid problems

May 16, 2011 at 9:28 PM

Hi, I am so close to getting this datagrid running but have a couple of small problems that I'm hoping someone can help me with.  I'm using MVC3 with Razor.

1. Whenever I click the Insert row button I get a JS error on the  jQuery.validator.unobtrusive.parseExt function in the MVCControlsToolkit.Controls-1.0.0.min.js file.  It basically says that ParseExt is null.  Its really weird I've done everything as said in the tutorial and I've checked the Razor example and it works fine.  Its just my use that is failing.  I've included all the JS files required and checked and double checked against the Example and I'm 99% sure I have everything as in the example.

2. I can't seem to be able to Save a row as there is no Save button on the row.  What I would like to do is go through each row at a time editing and saving but it appears you have to save the whole grid at once...is this the only way to do it?

Cheers,

Craig

May 16, 2011 at 9:36 PM

Also 1 other problem:

I want to start with an empty grid which the user populates.  However when I do the "Add" button doesn't show.  It appears there has to be at least 1 item in the grid.  Is there a way around this?

Thanks,

Craig

May 17, 2011 at 3:13 AM

OK, first problem was my fault.  I was re-importing the js scripts in sub pages.  Removed now.  Also point 2 I can live with since I will start with a blank grid and simply add as many items as I want.

Point 3 however is one that has me stumped.  Anyway we can get the Insert template to run when there are no items in the grid?

Thanks,

Craig

May 17, 2011 at 8:26 AM

I have implemented a quick fix to the source code to enable me to add items to the grid for empty lists.  I simply added this line to the DataGridHelper.DataGridFor<> method:

if (insertClosedPosition == -1) insertClosedPosition = 0;

 

I placed this on line 961 just before the check:

if

(addDisplayTemplate != null && editTemplate != null && insertClosedPosition != normalElementCount-1)

  

Hope that helps in fixing it.

Cheers,

Craig

 

Coordinator
May 17, 2011 at 6:25 PM

Hi Craig,

The add row problem was a well known bug. I will fix it in the beta2 version that I will release in a few days...and that contain also some other bug fixes, and other some small improvement to some helper calls

(some parameter more to make some of them more flexible).

Thanks for your feedback!

About Row saving, note what follows. Mostf od datagrid you can find allow JUST to save A SINGLE Row because they HAVE NOT the technology to handle properly batch save of all rows with either 

client-side or server side validation and with change tracking, ....not because this is a better option.

Anyway, if you prefer you can modify ALSO each row and send it to the sever. To Do this simply avoid inserting an editt template or to set the edit option if you are using a ThemedDataGrid. This way

the datagrid will not go in edit mode. Use instead a detali link that allow you to open a detail window on the selected record, where you can change the record and submit to the server via AJAX.

After the server update also the row in the grid will be updated with the new values. Here the documentation on the detail form: http://mvccontrolstoolkit.codeplex.com/wikipage?title=DetailFormFor%20Helper

When you are in batch mode instead you have to submit all changed rows as explained in the examples.