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.
Unfortunately, activation email could not send to your email. Please try again.

Grid - Custom readonly Row

Thread ID:

Created:

Updated:

Platform:

Replies:

121827 Jan 28,2016 02:48 PM Feb 1,2016 12:48 AM ASP.NET MVC 6
loading
Tags: Grid
Prasanth
Asked On January 28, 2016 02:48 PM

Hi there,

Is there a way to make a specific row read-only based on a column value i.e. Current user ID. Let's say an employ can see all the orders within the company but only able to edit his/her orders. I am not sure whether this can be achieved through server side.

I am using ASP.NET authentication and can get the user information through HttpContext.User.

Regards
Prasanth

Prasanth
Replied On January 28, 2016 02:54 PM

Hi there,

Adding more to the query:

Also how can a column be made read-only based on another column value e.g. Boolean or DateTime

Regards
Prasanth

Prasanna Kumar Viswanathan [Syncfusion]
Replied On January 29, 2016 06:00 AM

Hi Prasanth,

Thanks for contacting Syncfusion support.

       Queries
                    Response

“Is there a way to make a specific row read-only based on a column value?”

Yes, we can make a specific row read-only by defining args.cancel as true in BeginEdit event of ejGrid. This event triggers before the record is edited. In this event, we get the row details in the arguments. Using for loop, we can get each column value and stop the editing by defining args.cancel as true.

Please find the code example and sample:

@(Html.EJ().Grid<Sample118577.Order>("FlatGrid")

.Datasource(Model)

.AllowSorting()

.AllowPaging()

.EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); })
    .ClientSideEvents(eve => eve.BeginEdit("beginedit").ActionComplete("querycell"))

------------------------------------------------

function beginedit(args) {

        var children = args.row.children();

        for( var i = 0 ; i < children.length ; i++)

        {

            if ($(children[i]).text() == "Brazil")

                args.cancel = true;

        }
    }


Sample: http://www.syncfusion.com/downloads/support/forum/121827/ze/Sample1185771817393863

Refer to the Help document for Beginedit event,

http://help.syncfusion.com/js/api/ejgrid#events:beginedit


“Also how can a column be made read-only based on another column value e.g. Boolean or DateTime”


We can make the column read only using actionComplete event of ejGrid. In this event, we check the condition with the requestType, and disable the CustomerID column by adding the disabled attribute.

Please find the code example and sample:


@(Html.EJ().Grid<Sample118577.Order>("FlatGrid")

.Datasource(Model)

.AllowSorting()

.AllowPaging()

.EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); })
    .ClientSideEvents(eve => eve.BeginEdit("beginedit").ActionComplete("querycell"))

---------------------------------------------------

function querycell(args) {

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

            var data = this.element.find(".e-editedrow").find("input");

            var input = this.element.find(".e-editedrow").find("input")[1];

            for (var i = 0 ; i < data.length ; i++) {

                if ($(data[i]).attr("value") == "false") {

                    $(input).attr("disabled", "disabled");

                }

            }

        }
    }



Refer to the following actionComplete event Help document,

http://help.syncfusion.com/js/api/ejgrid#events:actioncomplete


Regards,
Prasanna Kumar N.S.V


Prasanth
Replied On January 29, 2016 06:04 AM

Hi Prasanna,

Thanks for the prompt reply will try your solution out.  

Also I have just posted another question related same project I am working on.  I know it's Friday but is there any chance of getting back to me before the weekend?  This is the link 
https://www.syncfusion.com/forums/121830/linked-grids-with-batchdatasource

Thanks again for the solution

Regards
Prasanth



Prasanth
Replied On January 29, 2016 08:02 AM

Hi Prasanna,

Ignore my previous request think I have figured it out

Regards
Prasanth

Prasanth
Replied On January 29, 2016 08:34 AM

Hi Prasanna,

Ignore my previous request think I have figured it out

Regards
Prasanth

No luck with the new question.. jumped the gun., to avoid confusion will wait for response on other thread .

Prasanna Kumar Viswanathan [Syncfusion]
Replied On February 1, 2016 12:48 AM

Hi Prasanth,

We will update the mentioned thread shortly.


Regards,

Prasanna Kumar N.S.V


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.

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.

;