This is a migrated thread and some comments may be shown as answers.

grid binding issue..Atanas from telerik team comment on this please...

9 Answers 58 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
ajmal
Top achievements
Rank 1
ajmal asked on 25 Apr 2011, 10:30 AM
Hello All,

attached is my sample project where i'm trying to bind the grid with Json list and I'm not defining columns for grid.

Atanas from telerik team write some comment at below link for this feature, will this feature available or is there any way to do as my columns are decided at run time.

http://www.telerik.com/community/forums/aspnet-mvc/grid/bind-grid-to-json-object.aspx

Please help..

9 Answers, 1 is accepted

Sort by
0
ajmal
Top achievements
Rank 1
answered on 26 Apr 2011, 01:06 PM

could some one comment on  this?

pleasew help
0
Atanas Korchev
Telerik team
answered on 26 Apr 2011, 01:17 PM
Hello ajmal,

 The grid needs to have predefined columns in order to be bound. Generating the columns in runtime on the client-side is not currently supported. As I said in the other forum thread we may implement it once there is more demand for auto generated columns on the client-side.

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
ajmal
Top achievements
Rank 1
answered on 26 Apr 2011, 01:31 PM
thnx a lot Atanas for your reply.

i'm looking for some alternate to hide columns..situation is like below.... there are 4 columns (col1 to col4).
if user select option 1 then show col1 & col2     .....  and if user select option 2 , then show col3 & col4.

all i'm doing through Json call...no postbak.

i able to do some by below code to show/hide the column, but once any column hide/show for option 1, then it will remain same for option 2..it works only first time...

is there any way to do like this...please help

@(Html.Telerik().Grid<BHN.PayGo.ASP.Model.Reports.HierarchyModel>()
               .Name("grdHierarchyContactInfo")
                   .Columns(columns =>
                   {
                       if (BHN.PayGo.ASP.Model.Reports.HierarchyModel.col1Show)
                       {
                           columns.Bound(o => o.AccountName).Title("Account Name").Width(75);
                       }
                       columns.Bound(o => o.AccountID).Title("Account ID").Width(75);
                       columns.Bound(o => o.AccountType).Title("Account Type").Width(75);
                       columns.Bound(o => o.Street1);
                       columns.Bound(o => o.Street2);
                       columns.Bound(o => o.City);
                       columns.Bound(o => o.State);
                       columns.Bound(o => o.Zip);
                       columns.Bound(o => o.Phone1);
                       columns.Bound(o => o.Phone2);
                       columns.Bound(o => o.Fax);
                       columns.Bound(o => o.Email);
                       columns.Bound(o => o.TestAccount);
                       columns.Bound(o => o.COL1);
                       columns.Bound(o => o.COL2);
                       columns.Bound(o => o.COL3);
                       columns.Bound(o => o.COL4);
                       columns.Bound(o => o.COL5);
                       columns.Bound(o => o.COL6);
                       columns.Bound(o => o.COL7);
                   })
               .ClientEvents(events => events.OnDataBinding("onDataBindingContactInfo"))
               .Sortable()
               .Pageable()
               .Scrollable(scrolling => scrolling.Enabled(true)))

//grid variables
       var gridContactInfo = $('#grdHierarchyContactInfo').data('tGrid');
       //account details type
       var AccountDetailsType = $("input:radio[name='AccountDetails']:checked").val();
       //get JSON data from the repective controller action
       //input parameter for controller's action is grid current page (always 1) and the page size
       $.getJSON('@Url.Action("HierarchyData", "Reports")', { pageNum: 1, pageSize: 10, accountDetailsType: AccountDetailsType }, function (result) {
           //total number of records
           totalRecords = result.total;
           //total records
           records = result.data;
           //bindGridContactInfo();
           gridContactInfo.dataBind(records);
           //set the grid to page 1
           gridContactInfo.currentPage = 1;

0
Atanas Korchev
Telerik team
answered on 26 Apr 2011, 01:39 PM
Hello ajmal,

 I can suggest an easier approach because hiding columns on the client-side may cause problems (cross browser issues).

 You can define more than one grid and show the required grid using jQuery.show(). To hide a grid simply set its display property to none:

Html.Telerik().Grid().HtmlAttributes( new { style = "display:none" } )

Then using jQuery.show you can easily show the right grid and hide the other grid.

Regards,

Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
ajmal
Top achievements
Rank 1
answered on 26 Apr 2011, 01:58 PM
thnx Atanas for quick reply. for 2 option it is easy to manage, but i having lots of options/combination of option, than in that case it is a huge pain to maintainability is also a huge task.

is there any other option through client side?

Thanks for help.
0
Atanas Korchev
Telerik team
answered on 26 Apr 2011, 02:11 PM
Hello ajmal,

 I can't think of any other option right now. The grid just does not support your requirement right now. 

Regards,

Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
ajmal
Top achievements
Rank 1
answered on 26 Apr 2011, 02:16 PM
ok..thnx Atanas...

BTW, when this feature will be available?
0
Atanas Korchev
Telerik team
answered on 26 Apr 2011, 03:05 PM
Hi ajmal,

 This feature is not scheduled for implementation yet so I cannot give a specific answer when it will be ready. Our roadmap for the next release is available here.

All the best,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
ajmal
Top achievements
Rank 1
answered on 28 Apr 2011, 07:12 AM
I found a work around for the same by calling the grid in partial views through Jquery load method. I put the same project in code library.

Thanks
Tags
Grid
Asked by
ajmal
Top achievements
Rank 1
Answers by
ajmal
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or