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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Disable Row based on Child Grid Records

Thread ID:

Created:

Updated:

Platform:

Replies:

122065 Feb 12,2016 11:07 PM UTC Feb 22,2016 12:24 PM UTC ASP.NET MVC 4
loading
Tags: Grid
Prasanth
Asked On February 12, 2016 11:07 PM UTC

Hi there,

I have two linked grids both of which use BatchDatasource with AdaptorType.UrlAdaptor.  Is there way to disable editing parent record if there are child records associated with the parent records

Regards
Prasanth

Prasanth
Replied On February 13, 2016 12:07 AM UTC

*EditMode(EditMode.Batch) Adaptor(AdaptorType.UrlAdaptor)

Jayaprakash Kamaraj [Syncfusion]
Replied On February 15, 2016 12:39 PM UTC

Hi Prasanth,
We are able to disable parent grid editing using its beginEdit event. This event triggers before the record is going to be edited. Disable the edit action by setting args.cancel as true. Please refer to the below code example.
Code Example:

beginEdit: function (args) {

if(args.type = "beginEdit")

    args.cancel = true;

}



If we have misunderstood your requirement ,Could you please share the following information to us, it will help us to provide the prompt solution:
                                                                                

1.       Do you want to disable editing in parent grid after selected the child grid records ?
2.       Please share more details about this query?

Regards,
 Jayaprakash K.            

Prasanth
Replied On February 21, 2016 11:45 AM UTC

Hi Jayaprakash,

Thanks for the reply.  you have sorted answered the question.

To disable  the parent row from editing I need to inspect the child grid (to see how many records) and set the row to uneditable 

e.g lets say we have list of orders displayed on parent row.  on child grid row, everytime a parent row is selected appropriate order items are listed.  i don't want users editing order main details on parent detials once items are populated.   i guess i could simply achieve this by disabling edit function but allow addition function.  however i do want people to change certain columns on parent grid also able to change anything on parent column if there are no children (in child grid)


also is it possible to temporarily disable addition functionality on parent grid if certain criteria is not met (e.g. if 5 orders listed on parent grid is not delivered )

I am sorry if I am being vague 

Let me know if there anything else you need from my side

Regards
Prasanth 

Jayaprakash Kamaraj [Syncfusion]
Replied On February 22, 2016 12:24 PM UTC

Hi Prasanth,

Query1: To disable  the parent row from editing I need to inspect the child grid (to see how many records) and set the row to uneditable 

We have achieved the requirement using cellEdit event, which triggers when the record is edited in cell. In this event, we find the child records count and prevent editing for parent Grid. Please refer to the below code example, Help documentation and sample.
Code example:

}).ClientSideEvents(eve=>eve.CellEdit("celledit").DataBound("databound")))

<script type="text/javascript">

    function databound(args) {

        if (args.model.currentViewData.length > 5)

            args.model.editSettings.allowAdding = false;

    }

    function celledit(args) {

        var index = args.model.selectedRowIndex;

        var childid = $(args.cell).parent().next().find(".e-grid").attr("id")

        var gridobj = $("#"+childid ).ejGrid("instance");

        var childRecords = gridobj.model.currentViewData;

        if (childRecords.length >= 1)

            args.cancel = true;

    }
</script>


Help documentation: http://help.syncfusion.com/js/api/ejgrid#events:celledit

Sample: http://www.syncfusion.com/downloads/support/forum/122065/ze/SyncfusionMvcApplication46-395000401


Query2: is it possible to temporarily disable addition functionality on parent grid if certain criteria is not met (e.g. if 5 orders listed on parent grid is not delivered )

The requirement can be achieved using databound event that triggers initial rendering of the Grid. In this event, we find the parent grid records and set allowAdding as false in parent Grid. Please refer to the below code example and Help documentation.
Code example:

}).ClientSideEvents(eve=>eve.CellEdit("celledit").DataBound("databound")))

<script type="text/javascript">

    function databound(args) {

        if (args.model.currentViewData.length > 5)

            args.model.editSettings.allowAdding = false;

    }

    function celledit(args) {

        var index = args.model.selectedRowIndex;

        var childid = $(args.cell).parent().next().find(".e-grid").attr("id")

        var gridobj = $("#"+childid ).ejGrid("instance");

        var childRecords = gridobj.model.currentViewData;

        if (childRecords.length >= 1)

            args.cancel = true;

    }
</script>


Help documentation: http://help.syncfusion.com/js/api/ejgrid#events:databound


Regards,


Jayaprakash K.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;