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
close icon

Add custom placeholder/watermark in textbox on edit or add new row

Hi,

I want to be able to add a placeholder in a textbox when editing or adding a new row in the grid.

Is there a simple way to do this?

Thanks,
Steve

1 Reply

PK Prasanna Kumar Viswanathan Syncfusion Team June 26, 2017 03:07 PM UTC

Hi Steve, 

Thanks for contacting Syncfusion support. 

To add a placeholder in textbox in a row, use actionComplete event of ejGrid. This event will be triggered for every grid success event. In this event we find the input elements of a newly added row and add the placeholder in the textbox. 

Find the code example:  


@(Html.EJ().Grid<object>("HierarchyGrid") 
         .Datasource((IEnumerable<object>)ViewBag.datasource) 
        ---------------------------- 
        .Columns(col => 
        { 
            ----------------------- 
        }) 
        .ClientSideEvents(eve => eve.ActionComplete("complete"))       
) 
 
<script> 
    function complete(args) { 
        if (args.requestType == "add" && args.requestType == "edit") { 
            var textboxes = this.element.find(".gridform").find("input"); 
            for (var i = 0 ; i < textboxes.length ; i++) { 
                $(textboxes[i]).attr("placeholder", "Enter Text"); 
            } 
        } 
    } 
</script> 


Refer to the Help document for the actionComplete event.  


Regards, 
Prasanna Kumar N.S.V 


Loader.
Live Chat Icon For mobile
Up arrow icon