Problem with repeating cell template

I've got a grid where I'm trying to use a templated editor (eventually, an InlineFormTemplate, but happens in all the templated forms). I've implemented the template based on samples in the documentation and that i've seen elsewhere on the forums.

The problem is that instead of just one record being represented in the editor, all the records in the grid are shown, with the first being the one that gets the EJ controls attached. Screenshot is at https://screencast.com/t/GpPwJF2nH. I don't see any exceptions in the browser debug window.

I can't reproduce the problem in a simple sample, unfortunately - even with mostly identical cshtml, varying only by the datamanager. I've included the page source below, in case there's anything obvious. Is there anything obvious that I can do to figure out why it's failing? Is it possible to get un-minified versious of the EJ scripts for debugging purposes?

@page "{handler?}"
@model Website.Pages.NewsAdminModel
   
@{
    ViewBag.Title = "News";
}

<ej-grid id="GridContainer"
         allow-resize-to-fit="true"
         allow-sorting="true"
         allow-text-wrap="true"
         allow-paging="true"
         is-responsive="true"
         enable-responsive-row="true"
         action-complete="complete">
  <e-datamanager url="/NewsAdmin/DataSource"
                 insert-url="/NewsAdmin/Insert"
                 remove-url="/NewsAdmin/Remove"
                 update-url="/NewsAdmin/Update"
                 adaptor="UrlAdaptor"
                 [email protected] />
  <e-edit-settings allow-adding="true"
                   allow-deleting="true"
                   allow-editing="true"
                   show-delete-confirm-dialog="true"
                   edit-mode="DialogTemplate"
                   dialog-editor-template-id="#iftemplate" />
  <e-toolbar-settings show-toolbar="true"
                      toolbar-items='new List<string>() {"add","edit","delete","update", "cancel"}' />
  <e-sort-settings>
    <e-sorted-columns>
      <e-sorted-column field="Title" direction="Ascending" />
    </e-sorted-columns>
  </e-sort-settings>
  <e-columns>
    <e-column field="NewsItemID" visible="false" is-primary-key="true" is-identity="true" />
    <e-column field="PublishDate"
              [email protected]
              />
    <e-column field="Title" />
    <e-column field="Text"
              width="100"
              clip-mode="Ellipsis"/>
    <e-column field="LinkText" />
    <e-column field="LinkUrl" />
  </e-columns>
</ej-grid>

<section Scripts>
  <script id="iftemplate" type="text/x-jsrender">
    <b>News Item Details</b> <input id="NewsItemID" name="NewsItemID" value="{{:NewsItemID}}"
 class="e-field e-ejinputtext valid e-disable"
                                    style="text-align: right; width: 116px; height: 28px"/>
    <table cellspacing="10">
        <tr>
            <td style="text-align: right;">
                Publish Date
            </td>
            <td style="text-align: left">
                <input id="PublishDate" name="PublishDate" value="{{:PublishDate}}" class="e-field e-ejinputtext valid"
                       style="width: 200px; height: 28px" />
            </td>
            <td style="text-align: right;">
                Title
            </td>
            <td style="text-align: left">
                <input id="Title" name="Title" value="{{:Title}}" class="e-field e-ejinputtext valid"
                       style="width: 200px; height: 28px" />
            </td>
        </tr>
        <tr>
            <td style="text-align: right;">
                Link Text
            </td>
            <td style="text-align: left">
                <input id="LinkText" name="LinkText" value="{{:LinkText}}" class="e-field e-ejinputtext valid"
                       style="width: 200px; height: 28px" />
            </td>
            <td style="text-align: right;">
                Link URL
            </td>
            <td style="text-align: left">
                <input id="LinkUrl" name="LinkUrl" value="{{:LinkUrl}}" class="e-field e-ejinputtext valid" type="url"
                       style="width: 200px; height: 28px" />
            </td>
        </tr>
        <tr>
            <td style="text-align: right;">
                Text
            </td>
            <td colspan="3">
                <textarea id="Text" rows="5" cols="60" style="height: 150px" name="Text"> {{:Text}}</textarea>
            </td>
        </tr>
    </table>
   
</script>

<script type="text/javascript">
    function complete(args) {
      if (args.requestType == "beginedit") {
        $("#PublishDate").ejDateTimePicker();
        $("#Text").ejRTE({ width: "100%" });
      }
    }
</script>
</section>

6 Replies

RS Renjith Singh Rajendran Syncfusion Team November 9, 2017 01:13 PM UTC

Hi R Brain, 

Thanks for contacting Syncfusion support. 

We have analyzed your query and screenshot. This issue arises when you have not set the is-primary-key property to a column. But we could see that the is-primary-key is set to the “NewsItemID” column. So we suggest you to check whether you have provided unique values in the data source for the is-primary-key column. 

Please get back to us if you need further details. 
 
We have also prepared a sample based on your requirement, which can be downloaded from the link below, 

Regards, 
Renjith Singh Rajendran. 



RB R Brian Lindahl November 9, 2017 02:58 PM UTC

Thank you! Turns out that I had a case error - the model had NewsItemId, and the form had NewsItemID. Will add this to my list of things to check when things go wrong. :)

brian



RB R Brian Lindahl November 10, 2017 12:20 AM UTC

The above works great now. However, I have another issue. In my previous sample, I have this in the template:

<input id="NewsItemID" name="NewsItemID" value="{{:NewsItemID}}"
 class="e-field e-ejinputtext valid e-disable"
                                    style="text-align: right; width: 116px; height: 28px"/>

without this present, an update operation fails because the NewsItemID that is passed back to the CRUD handler is 0, which gets posted as a new record (entity framework update apparently posts a new record in this situation). During an insert operation, the ID isn't present, which successfully inserts a new record. .

with the above, the update succeeds, but the insert fails due to the null being passed back from the <input>.

any suggestions on how to proceed?

brian



RS Renjith Singh Rajendran Syncfusion Team November 10, 2017 05:19 PM UTC

Hi R Brain,

 

We have analyzed your query. We could see that you have set is-identity property for the “NewsItemID” column. The is-identity property automatically sets the value as 0 to the columns at client side. So at every time you add it returns as 0, until you handle it at server side. So we suggest you to handle the insert operation of the particular column which you have provided the is-identity property at sever side by providing the value to the column, since by the default the value for the column will be set as 0.

 

Please get back to us if you need further assistance.

Regards,

Renjith Singh Rajendran.



RB R Brian Lindahl November 11, 2017 06:26 PM UTC

Slight change to the issue: if i set the NewsItemID column to be visible, I see that there are non-zero values for all the records. If I edit a record, and then save it, the NewsItemID isn't passed back to the server. This results in it being 0 server-side.

It looks like the only values being passed to CRUD are those that are in the form:

  1. {value: {PublishDate: "2017-11-10T16:05:29.000Z", Title: "asdf", LinkText: null, LinkUrl: null,…},…}
    1. action:"update"
    2. keyColumn:"NewsItemID"
    3. params:{}
    4. table:null
    5. value:{PublishDate: "2017-11-10T16:05:29.000Z", Title: "asdf", LinkText: null, LinkUrl: null,…}
      1. LinkText:null
      2. LinkUrl:null
      3. PublishDate:"2017-11-10T16:05:29.000Z"
      4. Text:" asdf"
      5. Text_formatDDL:"<p>"
      6. Text_formatDDL_hidden:"Paragraph"
      7. Text_order:null
      8. Text_orderdrpbtn:null
      9. Text_unorder:null
      10. Text_unorderdrpbtn:null
      11. Title:"asdf"

It doesn't seem to matter if is-identity is set or not. with it set, it still doesn't set the ID to 0 for a new record.

the only workaround I've found is to (a) have the hidden form field for NewsItemID and set default="0" for the NewsItemID column. This fills the hidden field with 0 for a new record and inserts the record correctly, and passed the original NewsItemID back for an edited record.



RS Renjith Singh Rajendran Syncfusion Team November 14, 2017 02:15 AM UTC

Hi R Brain, 

We have analyzed your query. We are not able to reproduce the reported issue. We have prepared a sample based on your requirement, which could be downloaded from the link below, 

If you are still facing this issue, please get back to us with the following details, 

  1. Share the screen shot or video demonstration of the issue.
  2. Share exact scenario or proper replication procedure.
  3. Share the stack trace of the issue if any script error occur in console window.
  4. If possible share the sample or reproduce the issue in the attached sample.
 
The provided information will help us to analyze the issue and provide you the response as early as possible. 

Regards, 
Renjith Singh Rajendran. 


Loader.
Up arrow icon