We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Cannot read property 'replace' of undefined

I am having trouble determining the cause of the following error:

Uncaught TypeError: Cannot read property 'replace' of undefined
    at Object.addDialogEditingTemplate (syncfusion?v=FHfwf1VEXuKT1aGrDV-JFsoW9t-9CzK0CnArdjh0qIk1:51)
    at Object._initiateTemplateRendering (syncfusion?v=FHfwf1VEXuKT1aGrDV-JFsoW9t-9CzK0CnArdjh0qIk1:51)
    at Object._processEditing (syncfusion?v=FHfwf1VEXuKT1aGrDV-JFsoW9t-9CzK0CnArdjh0qIk1:51)
    at Object._initGridRender (syncfusion?v=FHfwf1VEXuKT1aGrDV-JFsoW9t-9CzK0CnArdjh0qIk1:51)
    at Object._initDataProcess (syncfusion?v=FHfwf1VEXuKT1aGrDV-JFsoW9t-9CzK0CnArdjh0qIk1:51)
    at Object.<anonymous> (syncfusion?v=FHfwf1VEXuKT1aGrDV-JFsoW9t-9CzK0CnArdjh0qIk1:51)
    at t.DataManager.<anonymous> (syncfusion?v=FHfwf1VEXuKT1aGrDV-JFsoW9t-9CzK0CnArdjh0qIk1:51)
    at j (DXR.axd?r=1_181,1_179,1_180,1_178,1_243,1_164,1_138,1_141,1_135,1_219,1_232,1_226,1_229,1_137,17_41…:2)
    at Object.fireWith [as resolveWith] (DXR.axd?r=1_181,1_179,1_180,1_178,1_243,1_164,1_138,1_141,1_135,1_219,1_232,1_226,1_229,1_137,17_41…:2)
    at t.DataManager.<anonymous>

SYMPTOMS: 
  • When my grid is initially loaded without any results and I have the allowAdding or allowEditing set to "true", I receive the error above. 
  • If I do not have either of those set to "true", I do not get the error. 
  • If my initial result set is not empty, I do not receive the error even if filters applied on subsequent requests result in no data.

I've attached the complete ejGrid initialization for reference.


Attachment: ejgridsnippet_e417ed16.zip

3 Replies

MS Mani Sankar Durai Syncfusion Team May 9, 2017 12:42 PM UTC

HI Matt, 
 
Thanks for contacting Syncfusion support. 
 
   We have analyzed your query and we are able to reproduce the reported issue. We confirmed that the issue with “script error throws when data is empty with command column” is a defect, and we have logged a defect report. The fix for this issue will included in our Volume 2 SP1, 2017 release expected to be out by the month of May, 2017. 
Until then we suggest you to follow the below work around which helps to solve the issue. 
If you need the headerText for the command column please assign headerText for it else if no need we suggest you to pass as empty string for the command column headerText. 
Refer the code example. 
$("#Grid").ejGrid({ 
                dataSource: [], 
                columns: [ 
                    { 
                        headerText: "", 
                        width: 30, 
                        commands: [ 
                            { type: ej.Grid.UnboundType.Edit, buttonOptions: { contentType: "imageonly", prefixIcon: "e-icon e-edit" } } 
                        ] 
                    }, 
... 
                     ], 
              editSettings: { 
                    allowAdding: true, 
                    allowEditing: true, 
                    editMode: ej.Grid.EditMode.InlineForm 
                }, 
                toolbarSettings: { showToolbar: true, toolbarItems: [ej.Grid.ToolBarItems.Add] } 
            }); 


We have also prepared a sample that can be downloaded from the below link. 
Refer the documentation link. 
Please let us know if you need further assistance. 
 
Regards, 
Manisankar Durai 
 
 



MA Matt Abercrombie May 9, 2017 03:50 PM UTC

Workaround is perfect! Thank you very much for the prompt response and solution.


MS Mani Sankar Durai Syncfusion Team May 10, 2017 03:54 AM UTC

Hi Matt, 

We are happy to hear that your problem has been solved. 

Please let us know if you need further assistance. 

Regards, 
Manisankar Durai. 


Loader.
Live Chat Icon For mobile
Up arrow icon