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

First row of grid removed if it is not updated

6 Answers 235 Views
Grid
This is a migrated thread and some comments may be shown as answers.
jovaughn
Top achievements
Rank 1
Iron
jovaughn asked on 03 Sep 2019, 05:42 PM

If I add several rows to my grid which is not bound to any data source, upon clicking the edit button of the first row and then clicking then edit of any other row. The first row of the grid is lost/deleted if the update button is not clicked.

This only happens a single time and never again after the first time it occurs on any action combination.

Would be helpful to know if there is a way to send only new items through the create transport instead of the entire grid also.

I've tried setting the model id, this doesn't fix the problem either problem.

 

<datasource>
        <schema>
            <model id="PrimaryId">
                <fields>
                    <field name="PrimaryId" default-value="1"></field>
                    <field name="PayDate" type="date" editable="true" nullable="false"></field>
                    <field name="ActivityStartDate" type="date" editable="true" nullable="false"></field>
                    <field name="ActivityEndDate" type="date" editable="true" nullable="false"></field>
                    <field name="ApprovalDeadlineDateTime" type="date" editable="true" nullable="false"></field>
                </fields>
            </model>
        </schema>
    </datasource>

 

logic to get around incorrect rows sent to controller through create transport

if (grid.dataSource.data().length == 0) {
            //defaulted today
            grid.addRow();
        }
        else {
            var newStartDate = AddDays(grid.dataSource.data()[grid.dataSource.data().length - 1].ActivityEndDate,1);
            var newEndDate = AddDays(newStartDate, 30);
            var newDeadline = AddDays(newEndDate, 5);
            var newPayDate = AddDays(newDeadline, 2);
 
            $("#PayrollPayRunGrid").data("kendoGrid").dataSource.pushInsert(grid.dataSource.data().length, {
                PrimaryId: currId,
                ActivityStartDate:newStartDate,
                ActivityEndDate: newEndDate,
                ApprovalDeadlineDateTime: newDeadline,
                PayDate: newPayDate,
            });
            currId++;
            grid.editRow($("#PayrollPayRunGrid tr:eq(" + (grid.dataSource.data().length) + ")"));
        }

 

6 Answers, 1 is accepted

Sort by
0
Preslav
Telerik team
answered on 06 Sep 2019, 01:09 PM

Hi Jovaughn,

I examined the provided information and based on it, I am afraid that I cannot determinate the cause of the issue.

Could you please provide a runnable project that I could test locally? This project will help me fully understand the case, and I will be able to provide assistance to the best of my knowledge.

 

Regards,
Preslav
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
jovaughn
Top achievements
Rank 1
Iron
answered on 09 Sep 2019, 03:14 PM

Included a GIF of the action.

 

After clicking the edit button on the first row, then clicking edit on another row, the first row disappears. I assume i'm missing an option somewhere. Setting the model id to something unique did not work for me.

 

I would prefer to do this using create and read data-source transports. But when I tried using those the create method sent the entire grid instead of only new records.

 

Full grid html, javascript is the same as above.

<kendo-grid name="PayrollPayRunGrid" selectable="single row" auto-bind="false" height="400" on-edit="AddToModel">
    <columns>
        <column field="PayrollCycleId" hidden="true" />
        <column field="GlFiscalYear" hidden="true" />
        <column title="Pay Date" field="PayDate" format="{0: dddd, MM/dd/yy}" />
        <column title="Activity Start Date" field="ActivityStartDate" format="{0: dddd, MM/dd/yy}" />
        <column title="Activity End Date" field="ActivityEndDate" format="{0: dddd, MM/dd/yy}" />
        <column title="Approval Deadline" field="ApprovalDeadlineDateTime" format="{0: dddd, MM/dd/yy}" />
        <column>
            <commands>
                <column-command name="edit" />
                <column-command name="destroy" />
            </commands>
        </column>
    </columns>
    <scrollable endless="true" />
    <editable mode="inline" enabled="true" confirmation="false" />
    <groupable enabled="false" />
    <sortable enabled="true" allow-unsort="false" initial-direction="desc" />
    <filterable enabled="true" />
    <datasource>
        <schema>
            <model id="PrimaryId">
                <fields>
                    <field name="PrimaryId" default-value="1"></field>
                    <field name="PayDate" type="date" editable="true" nullable="false"></field>
                    <field name="ActivityStartDate" type="date" editable="true" nullable="false"></field>
                    <field name="ActivityEndDate" type="date" editable="true" nullable="false"></field>
                    <field name="ApprovalDeadlineDateTime" type="date" editable="true" nullable="false"></field>
                </fields>
            </model>
        </schema>
    </datasource>
    <toolbar>
        <toolbar-button template="ButtonTemplate">
        </toolbar-button>
    </toolbar>
</kendo-grid>
0
Preslav
Telerik team
answered on 12 Sep 2019, 03:51 PM

Hi Jovaughn,

I checked the video and the code.

I tested different scenarios, and the only time that I was able to replicate a behavior similar to the demonstrated one, is when my "Model.Id" is not set or is incorrect.

Having said that, could you please confirm that the "PrimaryId" string is exactly the same as the property in the model(case sensitive)? If this is the case, could you check if adding another Number property as an Id fixes the problem? For example:

<model id="Id">
    <fields>
        <field name="Id" type="number" />
...

Regards,
Preslav
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
jovaughn
Top achievements
Rank 1
Iron
answered on 12 Sep 2019, 04:59 PM

I am not sure what you mean by adding a new number property as an id. I tried adding a new "PrimaryId2" property and still got the same results.

PrimaryId is arbitrary and not used for anything besides having the required unique field.

When the Model Id is not set, I get a different result. Every row that is not updated is lost, which is expected. My issue only occurs on the first row of the grid a single time.

Changing pushInsert to pushCreate also has the same issue.

I also changed my id to a single uppercase letter and still get the same result.

grid.dataSource.pushInsert(grid.dataSource.data().length, {
               //arbitrary "A" property
               A: currId,
               ActivityStartDate:newStartDate,
               ActivityEndDate: newEndDate,
               ApprovalDeadlineDateTime: newDeadline,
               PayDate: newPayDate,
           });
           currId++;

 

<model id="A">
               <fields>
                   <field name="A" type="number"></field>
                   <field name="PayDate" type="date" editable="true" nullable="false"></field>
                   <field name="ActivityStartDate" type="date" editable="true" nullable="false"></field>
                   <field name="ActivityEndDate" type="date" editable="true" nullable="false"></field>
                   <field name="ApprovalDeadlineDateTime" type="date" editable="true" nullable="false"></field>
               </fields>
           </model>

0
Preslav
Telerik team
answered on 17 Sep 2019, 03:31 PM

Hi Jovaughn,

You understood me correctly and tried adding the "PrimaryId2" property. I am sorry to hear that this did not help.

Honestly speaking, I am out of ideas what might cause this faulty behavior. Having said that, in order to continue my investigation, I will need a runnable project that I could debug locally. Could you please prepare such a project?

Regards,
Preslav
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
jovaughn
Top achievements
Rank 1
Iron
answered on 17 Sep 2019, 04:39 PM
Ended up going with a remote datasource bound option that seems to work. Thanks for the help though.
Tags
Grid
Asked by
jovaughn
Top achievements
Rank 1
Iron
Answers by
Preslav
Telerik team
jovaughn
Top achievements
Rank 1
Iron
Share this question
or