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

Grid CRUDModel

Hi Syncfusion Team Support

I try to implement the grid CRUD model, basically in my view, i have this code

 <ej-grid id="FlatGrid"
                                 allow-paging="true"
                                 allow-filtering="true"
                                 filter-settings="@(new FilterSettings() { FilterType=FilterType.Excel}) "
                                 allow-sorting="true">
                            <e-datamanager json="ViewBag.datasource"
                                           update-url="/Medical/SaveMedicalConfig"
                                           insert-url="/Medical/SaveMedicalConfig"
                                           remove-url="/Medical/SaveMedicalConfig"
                                           adaptor="remoteSaveAdaptor" />
                            <e-edit-settings allow-adding="true" allow-editing="true" allow-deleting="true" dialog-editor-template-id="#templateJHProfile" edit-mode="@(EditMode.Normal)"></e-edit-settings>
                            <e-toolbar-settings show-toolbar="true" toolbar-items="@(new List<string>() {"add","edit","update","cancel" })"></e-toolbar-settings>
                            <e-columns>
                                <e-column field="ReferenceId" header-text="Action" is-primary-key="true" width="30" visible="false"></e-column>
                                <e-column field="ReferenceTypeId" header-text="Action" is-primary-key="false" width="30" visible="false"></e-column>
                                <e-column field="ReferenceTypeDesc" header-text="Category" edit-type="@(EditingType.Dropdown)" is-primary-key="true" width="75"></e-column>
                                <e-column field="Description" header-text="Description" is-primary-key="false" width="250"></e-column>
                            </e-columns>
                        </ej-grid>

which currently i have four column which is
1. ReferenceId          : this hold the running no from database, visible is false
2. ReferenceTypeId     : hold the drop down id no , visibla false
3. ReferenceTypeDesc     : hold the desc drop down
4. Description     : hold the text

as per in my attachment

Attachment: Grid_CRUD_1ada12fe.rar

3 Replies

SA Saravanan Arunachalam Syncfusion Team September 28, 2017 05:38 AM UTC

Hi Haryzad, 
Thanks for contacting Syncfusion’s support. 
We have analyzed your provided code, the cause of the issue is that you have hided the primary key fields and those hided fields are not update while save the edited record. So, we suggest you to update that primary key fields using action-begin event of Grid control and please refer to the below code example. 
<ej-grid id="FlatGrid" 
         allow-paging="true" 
         allow-filtering="true" 
         filter-settings="@(new FilterSettings() { FilterType=FilterType.Excel})" 
         action-begin="onBegin" 
         allow-sorting="true"> 
             . . . 
</ej-grid> 
<script type="text/javascript"> 
    function onBegin(args) { 
        if (args.requestType == "save") { 
            //Assign the customized value 
            args.data.ReferenceId = 5; 
            args.data.ReferenceTypeId = 6573; 
        } 
    } 
</script> 
 
Regards, 
Saravanan A. 



HA haryzad September 28, 2017 07:56 AM UTC

Thanks Saravanan A. 

Will try to implement it, btw why after i perform the grid action (save / edit / update), the grid content not refresh.

<ej-grid id="FlatGridmaklumatRawatan"

                                             allow-paging="true"

                                             allow-filtering="true" filter-settings="@(new FilterSettings() { FilterType=FilterType.Excel}) "

                                             action-complete="oncomplete"

                                             action-begin="oncomplete"

                                             allow-sorting="true">

                                        <e-datamanager json="ViewBag.datasourceTreatmentProfile"

                                                       update-url="/Medical/SaveTreatmentProfile"

                                                       insert-url="/Medical/SaveTreatmentProfile"

                                                       remove-url="/Medical/SaveTreatmentProfile"

                                                       adaptor="remoteSaveAdaptor" />

                                        <e-edit-settings allow-adding="true" allow-editing="true" allow-deleting="true" dialog-editor-template-id="#templateJHProfile" edit-mode="@(EditMode.Normal)"></e-edit-settings>

                                        <e-toolbar-settings show-toolbar="true" toolbar-items="@(new List<string>() {"edit","update","cancel" })"></e-toolbar-settings>

                                        <e-columns>

                                            <e-column field="JhId" header-text="Action" is-primary-key="true" width="30" visible="false"></e-column>

                                            <e-column field="ReferenceId" header-text="Action" is-identity="true" is-primary-key="true" width="30" visible="false"></e-column>

                                            <e-column field="ReferenceTypeId" header-text="Action" is-identity="true" is-primary-key="false" width="30" visible="false"></e-column>

                                            <e-column id="ReferencedropDown" field="ReferenceTypeDesc" header-text="Penyakit" is-primary-key="true" width="250" visible="false"></e-column>

                                            <e-column field="Description" header-text="Keterangan Penyakit" is-primary-key="true" width="70"></e-column>

                                            <e-column field="StatusRawatanPenyakit" header-text="Status" edit-type="@(EditingType.BooleanEdit)" width="25"></e-column>

                                        </e-columns>

                                    </ej-grid>


<script type="text/javascript">


    function oncomplete(args) {

        if (args.requestType == "edit") { 

            args.refreshContent();

        }

    }

</script>



Attachment: grid_refresh_ef6f58d3.rar


SA Saravanan Arunachalam Syncfusion Team September 29, 2017 04:59 AM UTC

Hi Haryzad, 
We are sorry that we are unable to reproduce your reported issue and we have created a sample that can be downloaded from the below link. 
And also we discussed this query in the following online demo which is refer from the below link. 
In the previous update, we have provided the details to update the hidden column (Primary key field) while saving the record which may be the cause of the issue. So, we suggest you to update the hidden column field when performing add action and please refer to the below code example. 
<ej-grid id="FlatGridmaklumatRawatan" 
         allow-paging="true" 
         allow-filtering="true" filter-settings="@(new FilterSettings() { FilterType=FilterType.Excel})" 
         action-begin="onBegin" 
         allow-sorting="true"> 
           . . . 
    </e-columns> 
</ej-grid> 
<script type="text/javascript"> 
    function onBegin(args) { 
        if (args.requestType == "save" && args.action == "add") { 
            args.data.OrderID = uniqueValue; 
 
        } 
 
    } 
</script> 
  
Regards, 
Saravanan A. 


Loader.
Up arrow icon