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 matlab实现基于主成分变换的图像融合。
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊