Help needed using Grid

I've come across 3 problems which I cannot resolve:

  1. I have a grid from which I have subscribed to ServerCommandButtonClick  and ServerRecordClick events. In this case only the ServerRecordClick event fires. 
  2. Also for the cells displayed as checkboxes clicking on the checkbox does not cause the ServerRecordClick event to fire.
  3. I also have a dialog control which should display when the ServerRecordClick event fires but does not.
I've attached a sample that shows the problems. 

TIA 

Nic

Attachment: SyncfusionGridanddialogtests_524f028e.zip

7 Replies

PK Prasanna Kumar Viswanathan Syncfusion Team May 4, 2018 08:55 AM UTC

Hi Adams, 

Thanks for contacting Syncfusion support. 

       Queries 
                                                  Response 

I have a grid from which I have subscribed to ServerCommandButtonClick  and ServerRecordClick events. In this case only the ServerRecordClick event fires” 


We checked the attached sample and we can reproduce the mentioned behavior in the attached sample.  

To fire the ServerCommandButtonClick event, we suggest you to define args.cancel as true in client-side recordClick event.    

In attached sample we bound client-side click event for commandButton and recordClick. When we click on commandButton  we set flag variable as false and if flag variable as false then we define args.cancel as true in recordClick event. So, the ServerRecordClick event does not fire.  

Find the code example:  

<ej:Grid ID="OrdersGrid" runat="server" ----- OnServerCommandButtonClick="OrdersGrid_ServerCommandButtonClick" OnServerRecordClick="OrdersGrid_ServerRecordClick"> 
            <TextWrapSettings WrapMode="Header" /> 
            <ClientSideEvents RecordClick="recordClick" /> 
            <EditSettings AllowEditing="false" /> 
            <Columns> 
            
              --------------------------- 
              <ej:Column HeaderText="Manage"> 
                <Command> 
                    <ej:Commands Type="Unlock"> 
                        <ButtonOptions Text="Unlock" Click="onClick" /> 
                    </ej:Commands> 
                    <ej:Commands Type="Reset"> 
                        <ButtonOptions Text="Reset password" Width="110" Click="onClick"/> 
                    </ej:Commands> 
                </Command> 
            </ej:Column> 
            </Columns> 
        </ej:Grid> 

----------------------------------------------------------------- 

<script type="text/javascript"> 
    var flag = true; 
 
    function onClick(args) { 
        flag = false 
    } 
 
    function recordClick(args) { 
        if (!flag) { 
            args.cancel = true; 
        } 
        flag = true; 
    } 
</script> 


 
Also for the cells displayed as checkboxes clicking on the checkbox does not cause the ServerRecordClick event to fire.” 
 


We checked in our sample by defining the checkbox column and we check on checkbox column the ServerRecordClick event is fired. So, we unable to reproduce the mentioned issue at our end.  

Find the code example:  

<Columns> 
              <ej:Column Type="checkbox"></ej:Column> 
              <ej:Column Field="OrderID" HeaderText="User" DataType="string"> 
              </ej:Column> 
              <ej:Column Field="CustomerID" HeaderText="Profile User" DataType="string"> 
              </ej:Column> 

To find out the root cause, we need the following details, 

1. Have you used template column in Grid to define the checkboxes?  

2. Have you faced any script error in your sample? If yes, Share the stackrace and screenshot of an issue.  

3. Share the code example of a Grid.  

 
I also have a dialog control which should display when the ServerRecordClick event fires but does not.” 
 


In this we suspect you need to display the dialog control when the ServerRecordClick event is fired. To achieve this, we suggest you to define showOnInit property as false at initial rendering.  

In ServerRecord click we need to define the showOnInit property as true to display the dialog control.  

Find the code example:  


<ej:Dialog ID="dialog" runat="server" ShowOnInit="false"></ej:Dialog> 
 
       <ej:Grid ID="OrdersGrid" runat="server" AllowResizeToFit="true" AllowTextWrap="true" AllowSelection="false" OnServerCommandButtonClick="OrdersGrid_ServerCommandButtonClick" OnServerRecordClick="OrdersGrid_ServerRecordClick"> 
            <TextWrapSettings WrapMode="Header" /> 
            --------------- 
              </ej:Column> 
 
----------------------------------------- 

protected void OrdersGrid_ServerRecordClick(object sender, GridEventArgs e) 
        { 
            this.dialog.ShowOnInit = true; 
        } 




Regards, 
Prasanna Kumar N.S.V 



NA Nic Adams May 4, 2018 04:34 PM UTC

Prasanna Kumar,

Thank you for your solutions. They are all working apart from the dialog - I cannot get it to display. 

I have attached my sample application updated as per your instructions. 

Please can you tell me my error?

Thanks

Nic

Attachment: TestSyncfusionGridAndDialog_41d5c61f.zip


TS Thavasianand Sankaranarayanan Syncfusion Team May 7, 2018 12:38 PM UTC

Hi Nic, 
  
We have downloaded your given attached file but there is no files inside your attachments.  
  
Please provide the following details for assistance. 
 
  1. Share attached files.
  2. Share screen shot or video demonstration of the issue.
  3. Share updated Grid code example.
  4. If possible share the issue reproducible sample or reproduce the issue in the previously attached sample.  
  
Regards, 
Thavasianand S. 



NA Nic Adams May 8, 2018 09:38 AM UTC

My Bad - please find the file attatched, correctly this time I hope.

Nic

Attachment: TestSyncfusionGridAndDialog_e9e9e20b.zip


TS Thavasianand Sankaranarayanan Syncfusion Team May 9, 2018 01:21 PM UTC

Hi Nic, 

We have analyzed your query and we are able to reproduce the reported issue “Dialog is not shown when selecting the record” from our end. This is not the recommended way So, we suggest you to follow the below code example. 


protected void gvUsers_ServerRecordClick(object sender, Syncfusion.JavaScript.Web.GridEventArgs e) 
        { 
            HtmlGenericControl divContent = new HtmlGenericControl("div"); 
            LiteralControl lit = new LiteralControl(); 
            lit.Text = "<h2>This is a Message</h2>"; 
            divContent.Controls.Add(lit);  // load the message content as like 
 
            this.dialog123.ShowOnInit = true; 
            this.dialog123.Title = "Hello"; 
            this.dialog123.DialogContent = divContent; // update it in the dialogcontent property 
            this.dialog123.IsResponsive = true; 
        } 


We have modified the sample and it can be downloadable from the below location. 


Regards, 
Thavasianand S. 



NA Nic Adams May 10, 2018 02:47 PM UTC

Thank you - I am now able to display a dialog.

Nic


TS Thavasianand Sankaranarayanan Syncfusion Team May 11, 2018 04:32 AM UTC

Hi Nic, 
 
We are happy that the problem has been solved. 
 
Please get back to us if you need any further assistance.  
                          
Regards, 
Thavasianand S.                         


Loader.
Up arrow icon