dongxiangshen7916 2017-08-07 07:50
浏览 87
已采纳

ExtJS RPC不适用于确切的类

I have API, written with Laravel. Class Example:

/**
* Class MRoleController
* @package App\Http\Controllers\API
*/

class MRoleAPIController extends BaseApiController
{
/** @var  MRoleRepository */
private $mRoleRepository;

public function __construct(MRoleRepository $mRoleRepo)
{
    $this->mRoleRepository = $mRoleRepo;
}

/**
 * @param Request $request
 * @return Response
 *
 * @SWG\Get(
 *      path="/m_roles",
 *      summary="Get a listing of the MRoles.",
 *      tags={"MRole"},
 *      description="#Get all MRoles",
 *      produces={"application/json"},
 *      @SWG\Response(
 *          response=200,
 *          description="successful operation",
 *          @SWG\Schema(
 *              type="object",
 *              @SWG\Property(
 *                  property="success",
 *                  type="boolean"
 *              ),
 *              @SWG\Property(
 *                  property="data",
 *                  type="array",
 *                  @SWG\Items(ref="#/definitions/MRole")
 *              ),
 *              @SWG\Property(
 *                  property="message",
 *                  type="string"
 *              )
 *          )
 *      )
 * )
 * 
 * @direct
 */
public function index($request = false)
{
    return parent::getAll($request, $this->mRoleRepository);
}

I have another classes with methods and RPC works with them correctly.

In browser console, I get two errors:

  1. Ext.direct.Manager.resolveApi(): Cannot resolve Direct API method 'API.MRole.index' for read action in Ext.data.proxy.Direct instance with id: unknown

  2. Uncaught Error: Cannot resolve Direct API method 'API.MRole.index' for read action in Ext.data.proxy.Direct instance with id: unknown

ExtJS model, where I try to use this class:

Ext.define('AIS.model.role', {
extend: 'Ext.data.Model',
alias: 'model.role',

requires: [
    'Project.DirectAPI',
    'Ext.data.field.Integer',
    'Ext.data.field.String',
    'Ext.data.proxy.Direct',
    'Ext.data.reader.Json'
],

idProperty: 'Role_id',

fields: [
    {
        type: 'int',
        name: 'RoleId'
    },
    {
        type: 'string',
        name: 'RoleName_RU'
    },
    {
        type: 'string',
        name: 'RoleName_UZ'
    },
    {
        type: 'string',
        name: 'RoleName_EN'
    }
],

proxy: {
    type: 'direct',
    api: {
        read: 'API.MRole.index',
        create: 'API.MRole.store',
        update: 'API.MRole.update',
        destroy: 'API.MRole.destroy'
    },
    reader: {
        type: 'json',
        rootProperty: 'data',
        totalProperty: 'totalCount'
    }
}
}); 

Thanks for your answers.

  • 写回答

1条回答 默认 最新

  • duancai1904 2017-08-07 09:54
    关注

    I solved the problem. It turns out, that I forgot to add "MRole" class to ext-direct.php config.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 远程桌面文档内容复制粘贴,格式会变化
  • ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题