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

Rad-Grid Batch mode Different Controls per Row

3 Answers 170 Views
Grid
This is a migrated thread and some comments may be shown as answers.
JJ
Top achievements
Rank 2
JJ asked on 11 Jul 2014, 02:18 PM
I can create different controls per column depending on data from code behind and it works.  

I want to create different controls per each row in code behind.
example:

                   <EditMode>
                    ColumnA             ColumnB
                    Row I:   RadComboBox         RadComboBox
                    Row II:  RadNumericTextBox   RadNumericTextBox
                    Row III: CheckBox            CheckBox
...

The problem is the Rad-grid Batch mode only have one Control in one Edit-template for each column, that means all the rows have the same Edit-template and control.

this I can do:


                ColumnA (RadComboBox)     ColumnB(RadNumericTextBox)
                Row I:   RadComboBox               RadNumericTextBox
                Row II:  RadComboBox               RadNumericTextBox
                Row III: RadComboBox               RadNumericTextBox

Is it possible to have Multiple Edit-templates per column or what is my alternatives? 

3 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 16 Jul 2014, 11:26 AM
Hello,

Although RadGrid does not allow such scenarios, where different editors will be used for each row, with Batch edit mode you could add all editors that will be used in a column in the EditItemTemplate and manually show the one that should be used for the current row and hide all of the others. This is the only possible approach, because with Batch edit mode there is only one rendered editor for each column, which is placed within a cell only when the cell/row is opened for editing.

However, please have in mind that this is a highly complex task and will need a huge amount of custom logic.

You could have a look at our online help article regarding Batch edit mode and see how to handle manually the setting and getting of the editor/cell values in a complex scenarios:
Hope this helps.


Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
JJ
Top achievements
Rank 2
answered on 16 Jul 2014, 03:20 PM
Thanks for the reply.

so with java-script I use the editor/cell values to select the type of control in the editor and play with the visible property?

We have done this option by setting the disabled property of the controls

function OnRowClick(sender, eventArgs) {

                 var PreRowID = eventArgs.get_id();
                 var strHasDetail = PreRowID.indexOf("Detail");

                 if (strHasDetail == "-1") {

                     var masterTable = $find("<%=rdGridXYZ.ClientID%>").get_masterTableView();

                     if (masterTable != null && masterTable != undefined && masterTable != NaN) {

                         var RowID = PreRowID.replace("ctl00_cphContent_rdGridXYZ_ctl00__", "");
                         var intRowID = parseInt(RowID);
                         var GridID = "" + sender.get_id();
                         
                         var Control_txt1 = masterTable.get_dataItems()[intRowID].findElement('txtForecast').id;
                        
                         CheckConditionAndDisableEnableControl(Control_txt1);


                        

                     }

                 }

}


 function CheckConditionAndDisableEnableControl(Control_txt1, strNewID, strNewID2) {

                 
                 var Controltxt1 = $("#" + Control_txt1);

 var Controltxt1OriginalId = "ctl00_cphContent_rdGridXYZ_ctl00_cphContent_rdGridXYZ_ctl00_ctl06_Detail10_TemplateColumn1_txt1";
                     var Controltxt1New_____Id = Controltxt1OriginalId.replace("ctl06", "ctl" + strNewID).replace("Detail10", "Detail" + strNewID2);

                     var Control_txt1New = $("#" + Controltxt1New_____Id);

                 var Control_txt1Color = $(Controltxt1).css("backgroundColor").toString();

                 if (Control_1Color == 'rgba(0, 0, 0, 0)') {
                     
                    

                     $(Control_txt1New).prop('disabled', false);

                 }
                 else {

                             $(Control_txt1New).prop('disabled', true);

                 }
                                                   
             }



...


 <ClientSettings 
                  AllowGroupExpandCollapse="false" 
                  AllowDragToGroup="false"
                  AllowExpandCollapse="false"
                  AllowRowsDragDrop="false" 
                  AllowRowHide="false" 
                  AllowColumnHide="false" 
                  AllowAutoScrollOnDragDrop="false" 
                  ClientEvents-OnCommand="ByPassPageLoader"
                  AllowColumnsReorder="True" 
                  ReorderColumnsOnClient="True"
                  >

                  <Resizing AllowColumnResize="True" EnableRealTimeResize="True" ResizeGridOnColumnResize="True" />
                  <Scrolling AllowScroll="True" UseStaticHeaders="True"  FrozenColumnsCount="2" SaveScrollPosition="true"   />

                <ClientEvents  OnRowClick="OnRowClick" />
                

            </ClientSettings>






0
Konstantin Dikov
Telerik team
answered on 17 Jul 2014, 02:07 PM
Hello,

As I have mentioned in my previous post, for such complex scenario it would not be enough to hide/show a particular control from the template, but instead, the OnBatchEditGetCellValue, OnBatchEditSetCellValue, OnBatchEditGetEditorValue and OnBatchEditSetEditorValue client-side events should be handled. Please take a look at our online help article for Batch editing and the "Handling advanced templates" section in particular:
Hope this helps.



Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
JJ
Top achievements
Rank 2
Answers by
Konstantin Dikov
Telerik team
JJ
Top achievements
Rank 2
Share this question
or