AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 11.02.2012, 07:16   #1  
Blog bot is offline
Blog bot
Участник
 
25,631 / 848 (80) +++++++
Регистрация: 28.10.2006
Solutions Monkey: Async call to display method from the EP via a web service for delay loading
Источник: http://blogs.msdn.com/b/solutions/ar...y-loading.aspx
==============
Dave Parslow from the EP dev team came out with this sample to demonstrates how to do a call to display method from the EP via a web service and have the result show up in the UI such as the grid async.

Sample xpo is attached with this blog post.

SampleService.asmx

This is a pretty generic pattern of taking an array of id keys and return an array of key/value pairs.Calls a find method to get a record and then calls the display method on that record. You could use the sample code provided and inherit from AsyncDisplayMethodService or build your own class based on the sample.



public class
SampleService : AsyncDisplayMethodService

{

public SampleService()

{


this.TableName = "Sample";

this.FindStaticMethodName = "find";

}



[WebMethod]

public IDValuePair[] GetTotal(string[] expenseNumbers) {


return this.CallDisplayMethod(expenseNumbers, "total");

}



[WebMethod]

public IDValuePair[] GetLineTotal(string[] expenseNumbers)

{


return this.CallDisplayMethod(expenseNumbers, "lineTotal");

}

}



EPAsyncDisplayMethod.ascx.cs:

This is the code that you would include in your code behind. It registers the base javascript include.Then registers the initialization code that would be specific to you.

var lineTotalAsync = new AsyncDisplayMethod();

// Just an ID for debugging.

lineTotalAsync.ID = 'lineTotalAsync';

// This would be the asmx for your web service

lineTotalAsync.WebService = 'SampleService.asmx';

lineTotalAsync.WebServiceOperation = 'GetLineTotal';

// IDSelector is a jQuery selector to find the ID to send to the web service

// You can go to jquery.com to learn more about jQuery selectors.

//GetBoundFieldCellSelector gets the basic jQuery selector to find an AxBoundField value

// If you do not have ID as a visible field on the grid,

// then you can create a template field with the ID value in a input type='hidden' field and

// then you put a jQuery selector for that field as the IDSelector instead of calling GetBoundFieldCellSelector.

lineTotalAsync.IDSelector =lineTotalAsync.GetBoundFieldCellSelector('LineNumber');

// lineTotalAsync is name of my display method that just returns an empty string as a placeholder

lineTotalAsync.ValueSelector = lineTotalAsync.GetBoundFieldCellSelector('lineTotalAsync**') + ' > span';

// The default is cache the results of the display method in the browser, however if your value of the display method can change then

// there is a method of invalidating the cache using CacheInvalidateSelector. In this example, the PriceUnit and QtyOrdered input fields can change the line total so

// Here we have the jQuery selector to use when those fields change that we invalidate the cache.

lineTotalAsync.CacheInvalidateSelector= lineTotalAsync.GetBoundFieldCellSelector('PriceUnit') + '> .AxInputField'

+ ', ' + lineTotalAsync.GetBoundFieldCellSelector('QtyOrdered') + '> .AxInputField';

lineTotalAsync.Initialize();





SampleDisplayMethod.ascx:













Sample table:

This the display method that will be called via JavaScript (lineTotalAsync and totalAsync).

This also has a display method that just acts as a placeholder for the real display method (lineTotalAsync and totalAsync).




==============
Источник: http://blogs.msdn.com/b/solutions/ar...y-loading.aspx
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Solutions Monkey: Migrating X++ web forms to AX 2009 EP asp.net framework Blog bot DAX Blogs 0 09.11.2010 19:05
Solutions Monkey: Move EP site from one machine to another Blog bot DAX Blogs 0 16.05.2009 11:05
Solutions Monkey: Integrating EP Web Parts to non-EP SharePoint sites Blog bot DAX Blogs 0 04.04.2009 03:19
Solutions Monkey: KPIs in Role Center Business Overview Web Part keeps loading all the time and never ends. Blog bot DAX Blogs 0 12.03.2009 07:05
Solutions Monkey: How to alternate the background color of each row in Web Grid in EP 4.0? Blog bot DAX Blogs 0 12.01.2008 12:31

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 21:09.