ASPX templates
Version 6.x > ASPX templates > Datagrid View modes: 
User avatar
Member
Member
Snarrak - 1/20/2012 7:21:46 AM
   
Datagrid
Hi,

I need a datagrid to show records in a custom table of my database.
There are a few things I need:
- At the beginning the datagrid contains all the records of the table.
- There are maybe 20 columns, but I just need half of them. So something with custom columns, or column bound.
- Above the datagrid I'm going to put some filters (dropdownlist), when the visitor selects a value in one of these filters, the other (not selected) values need to be removed from the datagrid.

There are a lot of possiblities:
- controls: CMSDataGrid, BasicDataGrid, QueryDataGrid, asp.net datagrid.
- databinding: query, entity framework, sql to linq etc. etc.

Does anyone had some experience with this, what do you think is the best way to do this?

Regards,
Jorik

User avatar
Member
Member
nicolas.juteau-nexun - 1/20/2012 8:53:44 AM
   
RE:Datagrid
Hi Jorik,

You can easily do this just by using the Kentico-provided webparts.

You will have to use the custom table datagrid webpart and the filter webpart. In the custom table datagrid webpart properties, you can specify which custom table to pull out data, select columns to display, wether or not paging the data, webpart name of the filter webpart, and so on... Speaking of the filter webpart, you will have to create your own .ascx filter and implement your filtering logic there. You can read this for more informations about developing custom filters.

Regards,
Nicolas

User avatar
Member
Member
Snarrak - 1/31/2012 6:42:19 AM
   
RE:Datagrid
Hi Nicolas,

Thanks for your respons.
What I forgot to mention, I'm working with a doctype because these are products that are needed in the webshop.

Is it still possible to work with the custom table and custom filter webpart?

Regards,
Jorik

User avatar
Member
Member
nicolas.juteau-nexun - 1/31/2012 12:26:36 PM
   
RE:Datagrid
Hello Jorik,

Is it still possible to work with the custom table and custom filter webpart?

No. As it's name says, the custom table datagrid is for custom tables only.

If you are working with a doctype, then you will have to use the Grid webpart. Its properties allows you to set the Path, Document types, Selected columns, Filter name, and so on. I suggest this reading for an exhaustive and detailed list of this webpart properties.

Then create your custom filter as explained in my first post and link it to the Grid webpart using the Filter name property. Once linked with the data source of the Grid webpart, all it does is add the WHERE and ORDER BY condition depending on your filtering logic.

Sorry about the confusion here, I really though you were talking about custom tables (created from CMS Desk -> Tools -> Custom tables)

I hope it will help you.

Regards,
Nicolas