Rad-Grid Batch mode Different Controls per Row

4 posts, 0 answers
  1. JJ
    JJ avatar
    21 posts
    Member since:
    Jul 2014

    Posted 11 Jul 2014 Link to this post

    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? 
  2. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1800 posts

    Posted 16 Jul 2014 Link to this post

    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.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. JJ
    JJ avatar
    21 posts
    Member since:
    Jul 2014

    Posted 16 Jul 2014 Link to this post

    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>






  5. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1800 posts

    Posted 17 Jul 2014 Link to this post

    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.

     
Back to Top