Especific query in Index

Sep 2, 2010 at 12:32 PM

Hello I am new to MVCCRUD, as I get in the Index I display a specific query and not all records?

 

thanks

Amadeo

Sep 2, 2010 at 12:49 PM
I try mapping the data with an SQL view using the repository pattern or otherwise do a custom view-model class with link to SQL, instanciate it in the controller and pass it to the view.  

Let me know what works best.

Claude

On Thu, Sep 2, 2010 at 8:32 AM, Amadeo <notifications@codeplex.com> wrote:

From: Amadeo

Hello I am new to MVCCRUD, as I get in the Index I display a specific query and not all records?

 

thanks

Amadeo

Read the full discussion online.

To add a post to this discussion, reply to this email (mvccrud@discussions.codeplex.com)

To start a new discussion for this project, email mvccrud@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com




--
Claude Bérubé, PMP
claude.berube@gmail.com
514-529-0338

http://clients.teksavvy.com/~cberube/

Sep 2, 2010 at 1:12 PM

Hi cberube, thanks for rapid response

mapping view I discarded because i need to pass parameters. I tried to create a new gridData, and call it from the grid since jsonURL, but not flame. Do you have any idea.

thank you very much in advance

 

Sep 2, 2010 at 3:27 PM
You are probably over complicating it.  I wouldn't use parameters. REST is a better pattern (using resources) and a core functionality of the framework. 
e.g. /mysite/myCustomView/id

You can use it to access custom views-model and instanciate the grid accordingly.

If you need specific grid features, you may try costumizing on the client side with jqGrid using javascript. You would then need to pass params to the view via a javascript object and apply them on the grid on page load using an init method.

Hope this helps. You can take a look at some articles on the MVC web site. I would try to stick to these patterns as they are best practice conventions.

Regards,

Claude

On Thu, Sep 2, 2010 at 9:12 AM, Amadeo <notifications@codeplex.com> wrote:

From: Amadeo

Hi cberube, thanks for rapid response

mapping view I discarded because i need to pass parameters. I tried to create a new gridData, and call it from the grid since jsonURL, but not flame. Do you have any idea.

thank you very much in advance

 

Read the full discussion online.

To add a post to this discussion, reply to this email (mvccrud@discussions.codeplex.com)

To start a new discussion for this project, email mvccrud@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com




--
Claude Bérubé, PMP
claude.berube@gmail.com
514-529-0338

http://clients.teksavvy.com/~cberube/

Sep 2, 2010 at 4:41 PM

Claude, thank you very much for your fast answers, but perhaps not express my problem well.

I have a model defined in Linq. Define the grid in this way in Repository

 public class xxxGrid : GenericDataGrid<tblxxx>    

{        

public ContactoADPGrid()            

:base("XXX1", "XXX", "/XXXControler/GridDataXXX/", "","", "", "ID", "FECHA",              

new[]  {  new DataGridCol("APELLIDO", "APELLIDO", 200), new DataGridCol("NOMBRE", "NOMBRE", 200),  new DataGridCol("FECHA","Fecha", 150),                                

     new DataGridCol("EMAIL", "e-mail", 200)                   })        

{            

base.editExecuteCheck = editExecuteCheck;

                        actionButtons.Add(new DataGridActionButton<tblxxx>            

{                title = "EXECACTION",                

classTag = "ui-icon ui-icon-arrowreturnthick-1-n",                

href = "/XXXControler/xxxAction/@0",                

parameters = new[] { "ID" },                

executeCheck = x => (x.FECHA== Convert.ToDateTime("01/01/1980"))            });

      }
    }

on the other hand, in the Controller

 

 public  ActionResult GridDataXXX(int id, string sidx, string sord, int page, int rows, bool _search, string searchField, string searchOper, string searchString)      

 {            

xxxRepository rep = new xxxRepository(repository.db);

        using (xxxGrid grid = new xxxGrid {items = Enumerable.Where(rep.All(), s => s.FECHA.Date == Convert.ToDateTime("01/01/1980")).AsQueryable() })            

{                return grid.GenerateGridData(sidx, sord, page, rows, _search, searchField, searchOper, searchString);

                 }

 }

But the method GridDataXXX is never called

 

this is my problem

Some idea?

Thank you very much in advance

 

 

 

 


Sep 3, 2010 at 11:45 AM

Hi Claude, I explain well my problem? could you understand me? if you can help me i'll thank you 

Regards 

Amadeo

Sep 3, 2010 at 5:01 PM
I haven't done any dynamic grids yet.   

The grid should be instanciated from the repository not in an actionResult from the controller, if it is the case.  

At last, the the grid is returned to the view via the model.rendergrid() method.

Repository
Your dynamic grid generation

Your controller
                ViewData.Model = new yourGrid( try to pass params to class constructor);
                return View("Index");

View
<%= Model.renderIncludes %>
<%= Model.renderGrid %>

It is a bit complicated of a process. You can find examples in the example project.

Let us know when you succeed.

Claude

On Fri, Sep 3, 2010 at 7:45 AM, Amadeo <notifications@codeplex.com> wrote:

From: Amadeo

Hi Claude, I explain well my problem? could you understand me? if you can help me i'll thank you 

Regards 

Amadeo

Read the full discussion online.

To add a post to this discussion, reply to this email (mvccrud@discussions.codeplex.com)

To start a new discussion for this project, email mvccrud@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com




--
Claude Bérubé, PMP
claude.berube@gmail.com
514-529-0338

http://clients.teksavvy.com/~cberube/

Sep 4, 2010 at 2:03 PM

Hi, Claude 

The example you sent me did not work. I had already tried something similar, with the ActionResult gridData from the controller. In the example works this way. JsonURL called in to "/ Product / ComponentGridData /", and the grid components in the view of Product. But in my case the grid does not call the ActionResult "/ XXXControler / GridDataXXX"
In my case this fact as in the example, System.Web.Mvc.ViewPage<ComponentGrid> or rendering the grid from the ViewData (ViewData ["ComponentGrid"] = new ComponentGrid (item.id)), as does the example, can you please guide me?

Thank you very much for your help

 


Sep 4, 2010 at 6:34 PM
Make sure you follow the example of the component in product edit section. It looks to be what you are looking for.  You shouldn't use any ActionResult in the controller. Use viewdata to send component to the view and trigger it from the view afterward.

You must be missing some code such as in the componentrepository. Look at the viewdata in the controller and in the view itself to make sure it is well configured.

Lo siento!

Regards,

Claude

On Sat, Sep 4, 2010 at 10:03 AM, Amadeo <notifications@codeplex.com> wrote:

From: Amadeo

Hi, Claude 

The example you sent me did not work. I had already tried something similar, with the ActionResult gridData from the controller. In the example works this way. JsonURL called in to "/ Product / ComponentGridData /", and the grid components in the view of Product. But in my case the grid does not call the ActionResult "/ XXXControler / GridDataXXX"
In my case this fact as in the example, System.Web.Mvc.ViewPage<ComponentGrid> or rendering the grid from the ViewData (ViewData ["ComponentGrid"] = new ComponentGrid (item.id)), as does the example, can you please guide me?

Thank you very much for your help

 


Read the full discussion online.

To add a post to this discussion, reply to this email (mvccrud@discussions.codeplex.com)

To start a new discussion for this project, email mvccrud@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com




--
Claude Bérubé, PMP
claude.berube@gmail.com
514-529-0338

http://clients.teksavvy.com/~cberube/

Sep 4, 2010 at 9:29 PM

Hello Claude, Thanks for answering all my questions.

I need it to display in the grid a selection of objects of a type and not all as it does by default.

I thank you for your help

Sep 5, 2010 at 12:49 AM
I suggest to make a custom class (view-model).  You can do it using linq to customize your properties then bind it the a custom grid repository. If you want full CRUD, I would try doing an SQL view this could give you full CRUD as a normal table. 

Good luck. Let me know how things are going.

Claude

On Sat, Sep 4, 2010 at 5:29 PM, Amadeo <notifications@codeplex.com> wrote:

From: Amadeo

Hello Claude, Thanks for answering all my questions.

I need it to display in the grid a selection of objects of a type and not all as it does by default.

I thank you for your help

Read the full discussion online.

To add a post to this discussion, reply to this email (mvccrud@discussions.codeplex.com)

To start a new discussion for this project, email mvccrud@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com




--
Claude Bérubé, PMP
claude.berube@gmail.com
514-529-0338

http://clients.teksavvy.com/~cberube/

Sep 5, 2010 at 5:49 PM

Hello Claude, I am grateful for your help. I have already tried in several ways. If you can send me an example, I'm a bit lost

 

Thank you very much for your help and your time

Sep 5, 2010 at 8:57 PM
I am really not sure dynamic grid will work.  All example I saw very done with static repositories.  

I would try one of these : 

1. Create an SQL  view to get your data directly form the DB and use a repository to populate the grid as a usual table.

2. Map a custom view-model with linq from your current repositories and send that model-view to the a custom grid.

There are tool that can help you for the second option.  As for the first one, it would be strait forward.

I suggest you to refer to these books.

For views : Head first SQL chapter 11.

For view-model  :  Microsoft.Press.Programming.Microsoft.ASP.NET.MVC.May.2010 chapter 6 page 286

Regards,

Claude


On Sun, Sep 5, 2010 at 1:49 PM, Amadeo <notifications@codeplex.com> wrote:

From: Amadeo

Hello Claude, I am grateful for your help. I have already tried in several ways. If you can send me an example, I'm a bit lost

 

Thank you very much for your help and your time

Read the full discussion online.

To add a post to this discussion, reply to this email (mvccrud@discussions.codeplex.com)

To start a new discussion for this project, email mvccrud@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com




--
Claude Bérubé, PMP
claude.berube@gmail.com
514-529-0338

http://clients.teksavvy.com/~cberube/

Apr 17, 2015 at 6:53 AM
you can visit very informative post here jQuery validation in MVC