w2bst2r
1/5/2019 - 11:24 AM

Some devexpress code blocks in views

// this code run when inserting button is clicked on      
 .OnInitNewRow(
                    @<text>
                        function(e) {
                        var value = $('[id *= "_MethodId"]').val();
                        alert(e.element.attr("id"));
                        }</text>)*      


//this function run when the dropbox is changed
var element;
    function GetIt() {
        element = $('[id *= "_MethodId"]');
        element.click(function () {
            alert("that changed!");       
        });
    }

OnContentReady works when the page is loaded
@(Html.DevExtreme().DataGrid<Order>()
    .ID("gridContainer")
    .OnContentReady(@<text>
        function(e) {
            alert(e.element.attr("id"));
        }</text>)

//this is the working version of method field
c.AddFor(x =>  x.MethodId).Visible(true).AllowFiltering(true).Caption("Method").ValidationRules(x => x.AddRequired())
.Lookup(lookup => lookup.DataSource(d =>  d.WebApi().Controller("ServiceMethod").LoadAction("Get").LoadParams(new  JS("getServiceId")).Key("MethodId"))
.ValueExpr("MethodId").DisplayExpr("MethodName")).FormItem(f =>  f.Visible(true));

//This transform a value to JSON format
data: "{service:'" + JSON.stringify(deger) + "'}",